﻿<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type='text/xsl' href="scriptsql.xsl"?>
<root xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database includeDrop="true">G24DATA</database>
<procedures>
		
		<procedure owner="dbo" name="tb_NhaCungCap_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NhaCungCap table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NhaCungCap],
					[NhaCungCap],
					[Ten],
					[MoTa],
					[HinhMinhHoa],
					[KhauHieu],
					[ChungThuc],
					[MaKichHoat],
					[KichHoat],
					[CamHoatDong],
					[Xoa],
					[DiaChi],
					[DienThoai],
					[Fax],
					[Website],
					[Email],
					[Vitri],
					[ThoiDiemTruyCap],
					[ThoiDiemThoat],
					[ThoiDiemCapNhat],
					[ThoiDiemChinhSua]
				FROM
					[dbo].[tb_NhaCungCap]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaCungCap_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaCungCap table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_NhaCungCap]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_NhaCungCap]'
				SET @SQL = @SQL + ', [NhaCungCap]'
				SET @SQL = @SQL + ', [Ten]'
				SET @SQL = @SQL + ', [MoTa]'
				SET @SQL = @SQL + ', [HinhMinhHoa]'
				SET @SQL = @SQL + ', [KhauHieu]'
				SET @SQL = @SQL + ', [ChungThuc]'
				SET @SQL = @SQL + ', [MaKichHoat]'
				SET @SQL = @SQL + ', [KichHoat]'
				SET @SQL = @SQL + ', [CamHoatDong]'
				SET @SQL = @SQL + ', [Xoa]'
				SET @SQL = @SQL + ', [DiaChi]'
				SET @SQL = @SQL + ', [DienThoai]'
				SET @SQL = @SQL + ', [Fax]'
				SET @SQL = @SQL + ', [Website]'
				SET @SQL = @SQL + ', [Email]'
				SET @SQL = @SQL + ', [Vitri]'
				SET @SQL = @SQL + ', [ThoiDiemTruyCap]'
				SET @SQL = @SQL + ', [ThoiDiemThoat]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ', [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaCungCap]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_NhaCungCap],'
				SET @SQL = @SQL + ' [NhaCungCap],'
				SET @SQL = @SQL + ' [Ten],'
				SET @SQL = @SQL + ' [MoTa],'
				SET @SQL = @SQL + ' [HinhMinhHoa],'
				SET @SQL = @SQL + ' [KhauHieu],'
				SET @SQL = @SQL + ' [ChungThuc],'
				SET @SQL = @SQL + ' [MaKichHoat],'
				SET @SQL = @SQL + ' [KichHoat],'
				SET @SQL = @SQL + ' [CamHoatDong],'
				SET @SQL = @SQL + ' [Xoa],'
				SET @SQL = @SQL + ' [DiaChi],'
				SET @SQL = @SQL + ' [DienThoai],'
				SET @SQL = @SQL + ' [Fax],'
				SET @SQL = @SQL + ' [Website],'
				SET @SQL = @SQL + ' [Email],'
				SET @SQL = @SQL + ' [Vitri],'
				SET @SQL = @SQL + ' [ThoiDiemTruyCap],'
				SET @SQL = @SQL + ' [ThoiDiemThoat],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat],'
				SET @SQL = @SQL + ' [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaCungCap]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NhaCungCap_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NhaCungCap table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@KhauHieu" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@ChungThuc" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@MaKichHoat" type="varchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@KichHoat" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@CamHoatDong" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Xoa" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@DiaChi" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@DienThoai" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@Fax" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Website" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@Vitri" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemTruyCap" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemThoat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NhaCungCap]
					(
					[ID_NhaCungCap]
					,[NhaCungCap]
					,[Ten]
					,[MoTa]
					,[HinhMinhHoa]
					,[KhauHieu]
					,[ChungThuc]
					,[MaKichHoat]
					,[KichHoat]
					,[CamHoatDong]
					,[Xoa]
					,[DiaChi]
					,[DienThoai]
					,[Fax]
					,[Website]
					,[Email]
					,[Vitri]
					,[ThoiDiemTruyCap]
					,[ThoiDiemThoat]
					,[ThoiDiemCapNhat]
					,[ThoiDiemChinhSua]
					)
				VALUES
					(
					@IDNhaCungCap
					,@NhaCungCap
					,@Ten
					,@MoTa
					,@HinhMinhHoa
					,@KhauHieu
					,@ChungThuc
					,@MaKichHoat
					,@KichHoat
					,@CamHoatDong
					,@Xoa
					,@DiaChi
					,@DienThoai
					,@Fax
					,@Website
					,@Email
					,@Vitri
					,@ThoiDiemTruyCap
					,@ThoiDiemThoat
					,@ThoiDiemCapNhat
					,@ThoiDiemChinhSua
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCap_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NhaCungCap table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@KhauHieu" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@ChungThuc" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@MaKichHoat" type="varchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@KichHoat" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@CamHoatDong" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Xoa" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@DiaChi" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault=""/>
				<parameter name="@DienThoai" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@Fax" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Website" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@Vitri" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemTruyCap" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemThoat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NhaCungCap]
				SET
					[ID_NhaCungCap] = @IDNhaCungCap
					,[NhaCungCap] = @NhaCungCap
					,[Ten] = @Ten
					,[MoTa] = @MoTa
					,[HinhMinhHoa] = @HinhMinhHoa
					,[KhauHieu] = @KhauHieu
					,[ChungThuc] = @ChungThuc
					,[MaKichHoat] = @MaKichHoat
					,[KichHoat] = @KichHoat
					,[CamHoatDong] = @CamHoatDong
					,[Xoa] = @Xoa
					,[DiaChi] = @DiaChi
					,[DienThoai] = @DienThoai
					,[Fax] = @Fax
					,[Website] = @Website
					,[Email] = @Email
					,[Vitri] = @Vitri
					,[ThoiDiemTruyCap] = @ThoiDiemTruyCap
					,[ThoiDiemThoat] = @ThoiDiemThoat
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
					,[ThoiDiemChinhSua] = @ThoiDiemChinhSua
				WHERE
[ID_NhaCungCap] = @OriginalIDNhaCungCap 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCap_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NhaCungCap table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NhaCungCap] WITH (ROWLOCK) 
				WHERE
					[ID_NhaCungCap] = @IDNhaCungCap
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCap_GetByIDNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCap table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NhaCungCap],
					[NhaCungCap],
					[Ten],
					[MoTa],
					[HinhMinhHoa],
					[KhauHieu],
					[ChungThuc],
					[MaKichHoat],
					[KichHoat],
					[CamHoatDong],
					[Xoa],
					[DiaChi],
					[DienThoai],
					[Fax],
					[Website],
					[Email],
					[Vitri],
					[ThoiDiemTruyCap],
					[ThoiDiemThoat],
					[ThoiDiemCapNhat],
					[ThoiDiemChinhSua]
				FROM
					[dbo].[tb_NhaCungCap]
				WHERE
					[ID_NhaCungCap] = @IDNhaCungCap
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCap_GetByNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCap table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NhaCungCap],
					[NhaCungCap],
					[Ten],
					[MoTa],
					[HinhMinhHoa],
					[KhauHieu],
					[ChungThuc],
					[MaKichHoat],
					[KichHoat],
					[CamHoatDong],
					[Xoa],
					[DiaChi],
					[DienThoai],
					[Fax],
					[Website],
					[Email],
					[Vitri],
					[ThoiDiemTruyCap],
					[ThoiDiemThoat],
					[ThoiDiemCapNhat],
					[ThoiDiemChinhSua]
				FROM
					[dbo].[tb_NhaCungCap]
				WHERE
					[NhaCungCap] = @NhaCungCap
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCap_GetByIDNguoiDungFromNguoiDungNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_NhaCungCap].[ID_NhaCungCap]
       ,dbo.[tb_NhaCungCap].[NhaCungCap]
       ,dbo.[tb_NhaCungCap].[Ten]
       ,dbo.[tb_NhaCungCap].[MoTa]
       ,dbo.[tb_NhaCungCap].[HinhMinhHoa]
       ,dbo.[tb_NhaCungCap].[KhauHieu]
       ,dbo.[tb_NhaCungCap].[ChungThuc]
       ,dbo.[tb_NhaCungCap].[MaKichHoat]
       ,dbo.[tb_NhaCungCap].[KichHoat]
       ,dbo.[tb_NhaCungCap].[CamHoatDong]
       ,dbo.[tb_NhaCungCap].[Xoa]
       ,dbo.[tb_NhaCungCap].[DiaChi]
       ,dbo.[tb_NhaCungCap].[DienThoai]
       ,dbo.[tb_NhaCungCap].[Fax]
       ,dbo.[tb_NhaCungCap].[Website]
       ,dbo.[tb_NhaCungCap].[Email]
       ,dbo.[tb_NhaCungCap].[Vitri]
       ,dbo.[tb_NhaCungCap].[ThoiDiemTruyCap]
       ,dbo.[tb_NhaCungCap].[ThoiDiemThoat]
       ,dbo.[tb_NhaCungCap].[ThoiDiemCapNhat]
       ,dbo.[tb_NhaCungCap].[ThoiDiemChinhSua]
  FROM dbo.[tb_NhaCungCap]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NguoiDungNhaCungCap] 
                WHERE dbo.[tb_NguoiDungNhaCungCap].[ID_NguoiDung] = @IDNguoiDung
                  AND dbo.[tb_NguoiDungNhaCungCap].[ID_NhaCungCap] = dbo.[tb_NhaCungCap].[ID_NhaCungCap]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCap_GetByIDDiaBanFromNhaCungCapDiaBan" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_NhaCungCap].[ID_NhaCungCap]
       ,dbo.[tb_NhaCungCap].[NhaCungCap]
       ,dbo.[tb_NhaCungCap].[Ten]
       ,dbo.[tb_NhaCungCap].[MoTa]
       ,dbo.[tb_NhaCungCap].[HinhMinhHoa]
       ,dbo.[tb_NhaCungCap].[KhauHieu]
       ,dbo.[tb_NhaCungCap].[ChungThuc]
       ,dbo.[tb_NhaCungCap].[MaKichHoat]
       ,dbo.[tb_NhaCungCap].[KichHoat]
       ,dbo.[tb_NhaCungCap].[CamHoatDong]
       ,dbo.[tb_NhaCungCap].[Xoa]
       ,dbo.[tb_NhaCungCap].[DiaChi]
       ,dbo.[tb_NhaCungCap].[DienThoai]
       ,dbo.[tb_NhaCungCap].[Fax]
       ,dbo.[tb_NhaCungCap].[Website]
       ,dbo.[tb_NhaCungCap].[Email]
       ,dbo.[tb_NhaCungCap].[Vitri]
       ,dbo.[tb_NhaCungCap].[ThoiDiemTruyCap]
       ,dbo.[tb_NhaCungCap].[ThoiDiemThoat]
       ,dbo.[tb_NhaCungCap].[ThoiDiemCapNhat]
       ,dbo.[tb_NhaCungCap].[ThoiDiemChinhSua]
  FROM dbo.[tb_NhaCungCap]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NhaCungCapDiaBan] 
                WHERE dbo.[tb_NhaCungCapDiaBan].[ID_DiaBan] = @IDDiaBan
                  AND dbo.[tb_NhaCungCapDiaBan].[ID_NhaCungCap] = dbo.[tb_NhaCungCap].[ID_NhaCungCap]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCap_GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_NhaCungCap].[ID_NhaCungCap]
       ,dbo.[tb_NhaCungCap].[NhaCungCap]
       ,dbo.[tb_NhaCungCap].[Ten]
       ,dbo.[tb_NhaCungCap].[MoTa]
       ,dbo.[tb_NhaCungCap].[HinhMinhHoa]
       ,dbo.[tb_NhaCungCap].[KhauHieu]
       ,dbo.[tb_NhaCungCap].[ChungThuc]
       ,dbo.[tb_NhaCungCap].[MaKichHoat]
       ,dbo.[tb_NhaCungCap].[KichHoat]
       ,dbo.[tb_NhaCungCap].[CamHoatDong]
       ,dbo.[tb_NhaCungCap].[Xoa]
       ,dbo.[tb_NhaCungCap].[DiaChi]
       ,dbo.[tb_NhaCungCap].[DienThoai]
       ,dbo.[tb_NhaCungCap].[Fax]
       ,dbo.[tb_NhaCungCap].[Website]
       ,dbo.[tb_NhaCungCap].[Email]
       ,dbo.[tb_NhaCungCap].[Vitri]
       ,dbo.[tb_NhaCungCap].[ThoiDiemTruyCap]
       ,dbo.[tb_NhaCungCap].[ThoiDiemThoat]
       ,dbo.[tb_NhaCungCap].[ThoiDiemCapNhat]
       ,dbo.[tb_NhaCungCap].[ThoiDiemChinhSua]
  FROM dbo.[tb_NhaCungCap]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NhaCungCapSanPhamDanhMuc] 
                WHERE dbo.[tb_NhaCungCapSanPhamDanhMuc].[ID_DiaBan] = @IDDiaBan
                  AND dbo.[tb_NhaCungCapSanPhamDanhMuc].[ID_NhaCungCap] = dbo.[tb_NhaCungCap].[ID_NhaCungCap]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCap_GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_NhaCungCap].[ID_NhaCungCap]
       ,dbo.[tb_NhaCungCap].[NhaCungCap]
       ,dbo.[tb_NhaCungCap].[Ten]
       ,dbo.[tb_NhaCungCap].[MoTa]
       ,dbo.[tb_NhaCungCap].[HinhMinhHoa]
       ,dbo.[tb_NhaCungCap].[KhauHieu]
       ,dbo.[tb_NhaCungCap].[ChungThuc]
       ,dbo.[tb_NhaCungCap].[MaKichHoat]
       ,dbo.[tb_NhaCungCap].[KichHoat]
       ,dbo.[tb_NhaCungCap].[CamHoatDong]
       ,dbo.[tb_NhaCungCap].[Xoa]
       ,dbo.[tb_NhaCungCap].[DiaChi]
       ,dbo.[tb_NhaCungCap].[DienThoai]
       ,dbo.[tb_NhaCungCap].[Fax]
       ,dbo.[tb_NhaCungCap].[Website]
       ,dbo.[tb_NhaCungCap].[Email]
       ,dbo.[tb_NhaCungCap].[Vitri]
       ,dbo.[tb_NhaCungCap].[ThoiDiemTruyCap]
       ,dbo.[tb_NhaCungCap].[ThoiDiemThoat]
       ,dbo.[tb_NhaCungCap].[ThoiDiemCapNhat]
       ,dbo.[tb_NhaCungCap].[ThoiDiemChinhSua]
  FROM dbo.[tb_NhaCungCap]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NhaCungCapSanPhamDanhMuc] 
                WHERE dbo.[tb_NhaCungCapSanPhamDanhMuc].[ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc
                  AND dbo.[tb_NhaCungCapSanPhamDanhMuc].[ID_NhaCungCap] = dbo.[tb_NhaCungCap].[ID_NhaCungCap]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCap_GetByIDNganhNgheKinhDoanhFromNhaCungCapNganhNgheKinhDoanh" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_NhaCungCap].[ID_NhaCungCap]
       ,dbo.[tb_NhaCungCap].[NhaCungCap]
       ,dbo.[tb_NhaCungCap].[Ten]
       ,dbo.[tb_NhaCungCap].[MoTa]
       ,dbo.[tb_NhaCungCap].[HinhMinhHoa]
       ,dbo.[tb_NhaCungCap].[KhauHieu]
       ,dbo.[tb_NhaCungCap].[ChungThuc]
       ,dbo.[tb_NhaCungCap].[MaKichHoat]
       ,dbo.[tb_NhaCungCap].[KichHoat]
       ,dbo.[tb_NhaCungCap].[CamHoatDong]
       ,dbo.[tb_NhaCungCap].[Xoa]
       ,dbo.[tb_NhaCungCap].[DiaChi]
       ,dbo.[tb_NhaCungCap].[DienThoai]
       ,dbo.[tb_NhaCungCap].[Fax]
       ,dbo.[tb_NhaCungCap].[Website]
       ,dbo.[tb_NhaCungCap].[Email]
       ,dbo.[tb_NhaCungCap].[Vitri]
       ,dbo.[tb_NhaCungCap].[ThoiDiemTruyCap]
       ,dbo.[tb_NhaCungCap].[ThoiDiemThoat]
       ,dbo.[tb_NhaCungCap].[ThoiDiemCapNhat]
       ,dbo.[tb_NhaCungCap].[ThoiDiemChinhSua]
  FROM dbo.[tb_NhaCungCap]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NhaCungCapNganhNgheKinhDoanh] 
                WHERE dbo.[tb_NhaCungCapNganhNgheKinhDoanh].[ID_NganhNgheKinhDoanh] = @IDNganhNgheKinhDoanh
                  AND dbo.[tb_NhaCungCapNganhNgheKinhDoanh].[ID_NhaCungCap] = dbo.[tb_NhaCungCap].[ID_NhaCungCap]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCap_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NhaCungCap table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault="null"/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault="null"/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@KhauHieu" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@ChungThuc" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@MaKichHoat" type="varchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@KichHoat" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@CamHoatDong" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Xoa" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@DiaChi" type="nvarchar" direction="Input" size="500" precision="0" scale="0" param="(500)" nulldefault="null"/>
				<parameter name="@DienThoai" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault="null"/>
				<parameter name="@Fax" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Website" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault="null"/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@Vitri" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemTruyCap" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemThoat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_NhaCungCap]
	, [NhaCungCap]
	, [Ten]
	, [MoTa]
	, [HinhMinhHoa]
	, [KhauHieu]
	, [ChungThuc]
	, [MaKichHoat]
	, [KichHoat]
	, [CamHoatDong]
	, [Xoa]
	, [DiaChi]
	, [DienThoai]
	, [Fax]
	, [Website]
	, [Email]
	, [Vitri]
	, [ThoiDiemTruyCap]
	, [ThoiDiemThoat]
	, [ThoiDiemCapNhat]
	, [ThoiDiemChinhSua]
    FROM
	[dbo].[tb_NhaCungCap]
    WHERE 
	 ([ID_NhaCungCap] = @IDNhaCungCap OR @IDNhaCungCap is null)
	AND ([NhaCungCap] = @NhaCungCap OR @NhaCungCap is null)
	AND ([Ten] = @Ten OR @Ten is null)
	AND ([HinhMinhHoa] = @HinhMinhHoa OR @HinhMinhHoa is null)
	AND ([KhauHieu] = @KhauHieu OR @KhauHieu is null)
	AND ([ChungThuc] = @ChungThuc OR @ChungThuc is null)
	AND ([MaKichHoat] = @MaKichHoat OR @MaKichHoat is null)
	AND ([KichHoat] = @KichHoat OR @KichHoat is null)
	AND ([CamHoatDong] = @CamHoatDong OR @CamHoatDong is null)
	AND ([Xoa] = @Xoa OR @Xoa is null)
	AND ([DiaChi] = @DiaChi OR @DiaChi is null)
	AND ([DienThoai] = @DienThoai OR @DienThoai is null)
	AND ([Fax] = @Fax OR @Fax is null)
	AND ([Website] = @Website OR @Website is null)
	AND ([Email] = @Email OR @Email is null)
	AND ([Vitri] = @Vitri OR @Vitri is null)
	AND ([ThoiDiemTruyCap] = @ThoiDiemTruyCap OR @ThoiDiemTruyCap is null)
	AND ([ThoiDiemThoat] = @ThoiDiemThoat OR @ThoiDiemThoat is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
	AND ([ThoiDiemChinhSua] = @ThoiDiemChinhSua OR @ThoiDiemChinhSua is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_NhaCungCap]
	, [NhaCungCap]
	, [Ten]
	, [MoTa]
	, [HinhMinhHoa]
	, [KhauHieu]
	, [ChungThuc]
	, [MaKichHoat]
	, [KichHoat]
	, [CamHoatDong]
	, [Xoa]
	, [DiaChi]
	, [DienThoai]
	, [Fax]
	, [Website]
	, [Email]
	, [Vitri]
	, [ThoiDiemTruyCap]
	, [ThoiDiemThoat]
	, [ThoiDiemCapNhat]
	, [ThoiDiemChinhSua]
    FROM
	[dbo].[tb_NhaCungCap]
    WHERE 
	 ([ID_NhaCungCap] = @IDNhaCungCap AND @IDNhaCungCap is not null)
	OR ([NhaCungCap] = @NhaCungCap AND @NhaCungCap is not null)
	OR ([Ten] = @Ten AND @Ten is not null)
	OR ([HinhMinhHoa] = @HinhMinhHoa AND @HinhMinhHoa is not null)
	OR ([KhauHieu] = @KhauHieu AND @KhauHieu is not null)
	OR ([ChungThuc] = @ChungThuc AND @ChungThuc is not null)
	OR ([MaKichHoat] = @MaKichHoat AND @MaKichHoat is not null)
	OR ([KichHoat] = @KichHoat AND @KichHoat is not null)
	OR ([CamHoatDong] = @CamHoatDong AND @CamHoatDong is not null)
	OR ([Xoa] = @Xoa AND @Xoa is not null)
	OR ([DiaChi] = @DiaChi AND @DiaChi is not null)
	OR ([DienThoai] = @DienThoai AND @DienThoai is not null)
	OR ([Fax] = @Fax AND @Fax is not null)
	OR ([Website] = @Website AND @Website is not null)
	OR ([Email] = @Email AND @Email is not null)
	OR ([Vitri] = @Vitri AND @Vitri is not null)
	OR ([ThoiDiemTruyCap] = @ThoiDiemTruyCap AND @ThoiDiemTruyCap is not null)
	OR ([ThoiDiemThoat] = @ThoiDiemThoat AND @ThoiDiemThoat is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	OR ([ThoiDiemChinhSua] = @ThoiDiemChinhSua AND @ThoiDiemChinhSua is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NhaCungCap_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaCungCap table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_NhaCungCap]
					, [NhaCungCap]
					, [Ten]
					, [MoTa]
					, [HinhMinhHoa]
					, [KhauHieu]
					, [ChungThuc]
					, [MaKichHoat]
					, [KichHoat]
					, [CamHoatDong]
					, [Xoa]
					, [DiaChi]
					, [DienThoai]
					, [Fax]
					, [Website]
					, [Email]
					, [Vitri]
					, [ThoiDiemTruyCap]
					, [ThoiDiemThoat]
					, [ThoiDiemCapNhat]
					, [ThoiDiemChinhSua]
					from [dbo].[tb_NhaCungCap] {0}
				)
				select
				       [ID_NhaCungCap],
				       [NhaCungCap],
				       [Ten],
				       [MoTa],
				       [HinhMinhHoa],
				       [KhauHieu],
				       [ChungThuc],
				       [MaKichHoat],
				       [KichHoat],
				       [CamHoatDong],
				       [Xoa],
				       [DiaChi],
				       [DienThoai],
				       [Fax],
				       [Website],
				       [Email],
				       [Vitri],
				       [ThoiDiemTruyCap],
				       [ThoiDiemThoat],
				       [ThoiDiemCapNhat],
				       [ThoiDiemChinhSua]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NhaCungCap] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_SanPhamBinhLuan_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_SanPhamBinhLuan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_SanPhamBinhLuan],
					[ID_SanPham],
					[TenSuDung],
					[TenNguoiDung],
					[Email],
					[NoiDung],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_SanPhamBinhLuan]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_SanPhamBinhLuan_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_SanPhamBinhLuan table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_SanPhamBinhLuan]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_SanPhamBinhLuan]'
				SET @SQL = @SQL + ', [ID_SanPham]'
				SET @SQL = @SQL + ', [TenSuDung]'
				SET @SQL = @SQL + ', [TenNguoiDung]'
				SET @SQL = @SQL + ', [Email]'
				SET @SQL = @SQL + ', [NoiDung]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_SanPhamBinhLuan]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_SanPhamBinhLuan],'
				SET @SQL = @SQL + ' [ID_SanPham],'
				SET @SQL = @SQL + ' [TenSuDung],'
				SET @SQL = @SQL + ' [TenNguoiDung],'
				SET @SQL = @SQL + ' [Email],'
				SET @SQL = @SQL + ' [NoiDung],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_SanPhamBinhLuan]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_SanPhamBinhLuan_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_SanPhamBinhLuan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPhamBinhLuan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TenSuDung" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
				<parameter name="@TenNguoiDung" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@NoiDung" type="nvarchar" direction="Input" size="3000" precision="0" scale="0" param="(3000)" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_SanPhamBinhLuan]
					(
					[ID_SanPhamBinhLuan]
					,[ID_SanPham]
					,[TenSuDung]
					,[TenNguoiDung]
					,[Email]
					,[NoiDung]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDSanPhamBinhLuan
					,@IDSanPham
					,@TenSuDung
					,@TenNguoiDung
					,@Email
					,@NoiDung
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPhamBinhLuan_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_SanPhamBinhLuan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPhamBinhLuan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDSanPhamBinhLuan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TenSuDung" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
				<parameter name="@TenNguoiDung" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@NoiDung" type="nvarchar" direction="Input" size="3000" precision="0" scale="0" param="(3000)" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_SanPhamBinhLuan]
				SET
					[ID_SanPhamBinhLuan] = @IDSanPhamBinhLuan
					,[ID_SanPham] = @IDSanPham
					,[TenSuDung] = @TenSuDung
					,[TenNguoiDung] = @TenNguoiDung
					,[Email] = @Email
					,[NoiDung] = @NoiDung
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_SanPhamBinhLuan] = @OriginalIDSanPhamBinhLuan 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPhamBinhLuan_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_SanPhamBinhLuan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPhamBinhLuan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_SanPhamBinhLuan] WITH (ROWLOCK) 
				WHERE
					[ID_SanPhamBinhLuan] = @IDSanPhamBinhLuan
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPhamBinhLuan_GetByIDSanPham" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_SanPhamBinhLuan table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_SanPhamBinhLuan],
					[ID_SanPham],
					[TenSuDung],
					[TenNguoiDung],
					[Email],
					[NoiDung],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_SanPhamBinhLuan]
				WHERE
					[ID_SanPham] = @IDSanPham
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPhamBinhLuan_GetByIDSanPhamBinhLuan" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_SanPhamBinhLuan table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPhamBinhLuan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_SanPhamBinhLuan],
					[ID_SanPham],
					[TenSuDung],
					[TenNguoiDung],
					[Email],
					[NoiDung],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_SanPhamBinhLuan]
				WHERE
					[ID_SanPhamBinhLuan] = @IDSanPhamBinhLuan
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_SanPhamBinhLuan_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_SanPhamBinhLuan table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDSanPhamBinhLuan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@TenSuDung" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault="null"/>
				<parameter name="@TenNguoiDung" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@NoiDung" type="nvarchar" direction="Input" size="3000" precision="0" scale="0" param="(3000)" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_SanPhamBinhLuan]
	, [ID_SanPham]
	, [TenSuDung]
	, [TenNguoiDung]
	, [Email]
	, [NoiDung]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_SanPhamBinhLuan]
    WHERE 
	 ([ID_SanPhamBinhLuan] = @IDSanPhamBinhLuan OR @IDSanPhamBinhLuan is null)
	AND ([ID_SanPham] = @IDSanPham OR @IDSanPham is null)
	AND ([TenSuDung] = @TenSuDung OR @TenSuDung is null)
	AND ([TenNguoiDung] = @TenNguoiDung OR @TenNguoiDung is null)
	AND ([Email] = @Email OR @Email is null)
	AND ([NoiDung] = @NoiDung OR @NoiDung is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_SanPhamBinhLuan]
	, [ID_SanPham]
	, [TenSuDung]
	, [TenNguoiDung]
	, [Email]
	, [NoiDung]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_SanPhamBinhLuan]
    WHERE 
	 ([ID_SanPhamBinhLuan] = @IDSanPhamBinhLuan AND @IDSanPhamBinhLuan is not null)
	OR ([ID_SanPham] = @IDSanPham AND @IDSanPham is not null)
	OR ([TenSuDung] = @TenSuDung AND @TenSuDung is not null)
	OR ([TenNguoiDung] = @TenNguoiDung AND @TenNguoiDung is not null)
	OR ([Email] = @Email AND @Email is not null)
	OR ([NoiDung] = @NoiDung AND @NoiDung is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_SanPhamBinhLuan_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_SanPhamBinhLuan table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_SanPhamBinhLuan]
					, [ID_SanPham]
					, [TenSuDung]
					, [TenNguoiDung]
					, [Email]
					, [NoiDung]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_SanPhamBinhLuan] {0}
				)
				select
				       [ID_SanPhamBinhLuan],
				       [ID_SanPham],
				       [TenSuDung],
				       [TenNguoiDung],
				       [Email],
				       [NoiDung],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_SanPhamBinhLuan] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTuc_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_TinTuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTuc],
					[ID_TinTucDanhMuc],
					[TieuDe],
					[MoTa],
					[NoiDung],
					[HinhMinhHoa],
					[MoTaHinh],
					[SolanXem],
					[NguonTin],
					[NhaCungCap],
					[TrangThai],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_TinTuc]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTuc_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTuc table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_TinTuc]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_TinTuc]'
				SET @SQL = @SQL + ', [ID_TinTucDanhMuc]'
				SET @SQL = @SQL + ', [TieuDe]'
				SET @SQL = @SQL + ', [MoTa]'
				SET @SQL = @SQL + ', [NoiDung]'
				SET @SQL = @SQL + ', [HinhMinhHoa]'
				SET @SQL = @SQL + ', [MoTaHinh]'
				SET @SQL = @SQL + ', [SolanXem]'
				SET @SQL = @SQL + ', [NguonTin]'
				SET @SQL = @SQL + ', [NhaCungCap]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ', [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTuc]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_TinTuc],'
				SET @SQL = @SQL + ' [ID_TinTucDanhMuc],'
				SET @SQL = @SQL + ' [TieuDe],'
				SET @SQL = @SQL + ' [MoTa],'
				SET @SQL = @SQL + ' [NoiDung],'
				SET @SQL = @SQL + ' [HinhMinhHoa],'
				SET @SQL = @SQL + ' [MoTaHinh],'
				SET @SQL = @SQL + ' [SolanXem],'
				SET @SQL = @SQL + ' [NguonTin],'
				SET @SQL = @SQL + ' [NhaCungCap],'
				SET @SQL = @SQL + ' [TrangThai],'
				SET @SQL = @SQL + ' [ThoiDiemChinhSua],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTuc]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_TinTuc_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_TinTuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TieuDe" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault=""/>
				<parameter name="@MoTa" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@NoiDung" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@MoTaHinh" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault=""/>
				<parameter name="@SolanXem" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@NguonTin" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_TinTuc]
					(
					[ID_TinTuc]
					,[ID_TinTucDanhMuc]
					,[TieuDe]
					,[MoTa]
					,[NoiDung]
					,[HinhMinhHoa]
					,[MoTaHinh]
					,[SolanXem]
					,[NguonTin]
					,[NhaCungCap]
					,[TrangThai]
					,[ThoiDiemChinhSua]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDTinTuc
					,@IDTinTucDanhMuc
					,@TieuDe
					,@MoTa
					,@NoiDung
					,@HinhMinhHoa
					,@MoTaHinh
					,@SolanXem
					,@NguonTin
					,@NhaCungCap
					,@TrangThai
					,@ThoiDiemChinhSua
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTuc_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_TinTuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TieuDe" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault=""/>
				<parameter name="@MoTa" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@NoiDung" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@MoTaHinh" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault=""/>
				<parameter name="@SolanXem" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@NguonTin" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_TinTuc]
				SET
					[ID_TinTuc] = @IDTinTuc
					,[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
					,[TieuDe] = @TieuDe
					,[MoTa] = @MoTa
					,[NoiDung] = @NoiDung
					,[HinhMinhHoa] = @HinhMinhHoa
					,[MoTaHinh] = @MoTaHinh
					,[SolanXem] = @SolanXem
					,[NguonTin] = @NguonTin
					,[NhaCungCap] = @NhaCungCap
					,[TrangThai] = @TrangThai
					,[ThoiDiemChinhSua] = @ThoiDiemChinhSua
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_TinTuc] = @OriginalIDTinTuc 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTuc_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_TinTuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_TinTuc] WITH (ROWLOCK) 
				WHERE
					[ID_TinTuc] = @IDTinTuc
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTuc_GetByIDTinTucDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTuc table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTuc],
					[ID_TinTucDanhMuc],
					[TieuDe],
					[MoTa],
					[NoiDung],
					[HinhMinhHoa],
					[MoTaHinh],
					[SolanXem],
					[NguonTin],
					[NhaCungCap],
					[TrangThai],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_TinTuc]
				WHERE
					[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTuc_GetByIDTinTuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTuc table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_TinTuc],
					[ID_TinTucDanhMuc],
					[TieuDe],
					[MoTa],
					[NoiDung],
					[HinhMinhHoa],
					[MoTaHinh],
					[SolanXem],
					[NguonTin],
					[NhaCungCap],
					[TrangThai],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_TinTuc]
				WHERE
					[ID_TinTuc] = @IDTinTuc
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_TinTuc_GetByIDTinTucDanhMucFromTinTucTieuDiem" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_TinTuc].[ID_TinTuc]
       ,dbo.[tb_TinTuc].[ID_TinTucDanhMuc]
       ,dbo.[tb_TinTuc].[TieuDe]
       ,dbo.[tb_TinTuc].[MoTa]
       ,dbo.[tb_TinTuc].[NoiDung]
       ,dbo.[tb_TinTuc].[HinhMinhHoa]
       ,dbo.[tb_TinTuc].[MoTaHinh]
       ,dbo.[tb_TinTuc].[SolanXem]
       ,dbo.[tb_TinTuc].[NguonTin]
       ,dbo.[tb_TinTuc].[NhaCungCap]
       ,dbo.[tb_TinTuc].[TrangThai]
       ,dbo.[tb_TinTuc].[ThoiDiemChinhSua]
       ,dbo.[tb_TinTuc].[ThoiDiemCapNhat]
  FROM dbo.[tb_TinTuc]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_TinTucTieuDiem] 
                WHERE dbo.[tb_TinTucTieuDiem].[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
                  AND dbo.[tb_TinTucTieuDiem].[ID_TinTuc] = dbo.[tb_TinTuc].[ID_TinTuc]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTuc_GetByIDTinTucDanhMucFromTinTucSuKien" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_TinTuc].[ID_TinTuc]
       ,dbo.[tb_TinTuc].[ID_TinTucDanhMuc]
       ,dbo.[tb_TinTuc].[TieuDe]
       ,dbo.[tb_TinTuc].[MoTa]
       ,dbo.[tb_TinTuc].[NoiDung]
       ,dbo.[tb_TinTuc].[HinhMinhHoa]
       ,dbo.[tb_TinTuc].[MoTaHinh]
       ,dbo.[tb_TinTuc].[SolanXem]
       ,dbo.[tb_TinTuc].[NguonTin]
       ,dbo.[tb_TinTuc].[NhaCungCap]
       ,dbo.[tb_TinTuc].[TrangThai]
       ,dbo.[tb_TinTuc].[ThoiDiemChinhSua]
       ,dbo.[tb_TinTuc].[ThoiDiemCapNhat]
  FROM dbo.[tb_TinTuc]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_TinTucSuKien] 
                WHERE dbo.[tb_TinTucSuKien].[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
                  AND dbo.[tb_TinTucSuKien].[ID_TinTuc] = dbo.[tb_TinTuc].[ID_TinTuc]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTuc_GetByIDTinTucChuDeFromTinTucTheoChuDe" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_TinTuc].[ID_TinTuc]
       ,dbo.[tb_TinTuc].[ID_TinTucDanhMuc]
       ,dbo.[tb_TinTuc].[TieuDe]
       ,dbo.[tb_TinTuc].[MoTa]
       ,dbo.[tb_TinTuc].[NoiDung]
       ,dbo.[tb_TinTuc].[HinhMinhHoa]
       ,dbo.[tb_TinTuc].[MoTaHinh]
       ,dbo.[tb_TinTuc].[SolanXem]
       ,dbo.[tb_TinTuc].[NguonTin]
       ,dbo.[tb_TinTuc].[NhaCungCap]
       ,dbo.[tb_TinTuc].[TrangThai]
       ,dbo.[tb_TinTuc].[ThoiDiemChinhSua]
       ,dbo.[tb_TinTuc].[ThoiDiemCapNhat]
  FROM dbo.[tb_TinTuc]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_TinTucTheoChuDe] 
                WHERE dbo.[tb_TinTucTheoChuDe].[ID_TinTucChuDe] = @IDTinTucChuDe
                  AND dbo.[tb_TinTucTheoChuDe].[ID_TinTuc] = dbo.[tb_TinTuc].[ID_TinTuc]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTuc_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_TinTuc table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@TieuDe" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault="null"/>
				<parameter name="@MoTa" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
				<parameter name="@NoiDung" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@MoTaHinh" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault="null"/>
				<parameter name="@SolanXem" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault="null"/>
				<parameter name="@NguonTin" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_TinTuc]
	, [ID_TinTucDanhMuc]
	, [TieuDe]
	, [MoTa]
	, [NoiDung]
	, [HinhMinhHoa]
	, [MoTaHinh]
	, [SolanXem]
	, [NguonTin]
	, [NhaCungCap]
	, [TrangThai]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_TinTuc]
    WHERE 
	 ([ID_TinTuc] = @IDTinTuc OR @IDTinTuc is null)
	AND ([ID_TinTucDanhMuc] = @IDTinTucDanhMuc OR @IDTinTucDanhMuc is null)
	AND ([TieuDe] = @TieuDe OR @TieuDe is null)
	AND ([MoTa] = @MoTa OR @MoTa is null)
	AND ([HinhMinhHoa] = @HinhMinhHoa OR @HinhMinhHoa is null)
	AND ([MoTaHinh] = @MoTaHinh OR @MoTaHinh is null)
	AND ([SolanXem] = @SolanXem OR @SolanXem is null)
	AND ([NguonTin] = @NguonTin OR @NguonTin is null)
	AND ([NhaCungCap] = @NhaCungCap OR @NhaCungCap is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
	AND ([ThoiDiemChinhSua] = @ThoiDiemChinhSua OR @ThoiDiemChinhSua is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_TinTuc]
	, [ID_TinTucDanhMuc]
	, [TieuDe]
	, [MoTa]
	, [NoiDung]
	, [HinhMinhHoa]
	, [MoTaHinh]
	, [SolanXem]
	, [NguonTin]
	, [NhaCungCap]
	, [TrangThai]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_TinTuc]
    WHERE 
	 ([ID_TinTuc] = @IDTinTuc AND @IDTinTuc is not null)
	OR ([ID_TinTucDanhMuc] = @IDTinTucDanhMuc AND @IDTinTucDanhMuc is not null)
	OR ([TieuDe] = @TieuDe AND @TieuDe is not null)
	OR ([MoTa] = @MoTa AND @MoTa is not null)
	OR ([HinhMinhHoa] = @HinhMinhHoa AND @HinhMinhHoa is not null)
	OR ([MoTaHinh] = @MoTaHinh AND @MoTaHinh is not null)
	OR ([SolanXem] = @SolanXem AND @SolanXem is not null)
	OR ([NguonTin] = @NguonTin AND @NguonTin is not null)
	OR ([NhaCungCap] = @NhaCungCap AND @NhaCungCap is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	OR ([ThoiDiemChinhSua] = @ThoiDiemChinhSua AND @ThoiDiemChinhSua is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_TinTuc_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTuc table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_TinTuc]
					, [ID_TinTucDanhMuc]
					, [TieuDe]
					, [MoTa]
					, [NoiDung]
					, [HinhMinhHoa]
					, [MoTaHinh]
					, [SolanXem]
					, [NguonTin]
					, [NhaCungCap]
					, [TrangThai]
					, [ThoiDiemChinhSua]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_TinTuc] {0}
				)
				select
				       [ID_TinTuc],
				       [ID_TinTucDanhMuc],
				       [TieuDe],
				       [MoTa],
				       [NoiDung],
				       [HinhMinhHoa],
				       [MoTaHinh],
				       [SolanXem],
				       [NguonTin],
				       [NhaCungCap],
				       [TrangThai],
				       [ThoiDiemChinhSua],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_TinTuc] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_SanPhamDanhMuc_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_SanPhamDanhMuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_SanPhamDanhMuc],
					[ID_SanPhamDanhMucCha],
					[Ten],
					[Mota],
					[HinhMinhHoa],
					[TrangThai],
					[ViTri],
					[SoLanXem],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_SanPhamDanhMuc]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_SanPhamDanhMuc_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_SanPhamDanhMuc table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_SanPhamDanhMuc]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_SanPhamDanhMuc]'
				SET @SQL = @SQL + ', [ID_SanPhamDanhMucCha]'
				SET @SQL = @SQL + ', [Ten]'
				SET @SQL = @SQL + ', [Mota]'
				SET @SQL = @SQL + ', [HinhMinhHoa]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ', [ViTri]'
				SET @SQL = @SQL + ', [SoLanXem]'
				SET @SQL = @SQL + ', [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_SanPhamDanhMuc]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_SanPhamDanhMuc],'
				SET @SQL = @SQL + ' [ID_SanPhamDanhMucCha],'
				SET @SQL = @SQL + ' [Ten],'
				SET @SQL = @SQL + ' [Mota],'
				SET @SQL = @SQL + ' [HinhMinhHoa],'
				SET @SQL = @SQL + ' [TrangThai],'
				SET @SQL = @SQL + ' [ViTri],'
				SET @SQL = @SQL + ' [SoLanXem],'
				SET @SQL = @SQL + ' [ThoiDiemChinhSua],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_SanPhamDanhMuc]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_SanPhamDanhMuc_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_SanPhamDanhMuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDSanPhamDanhMucCha" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault=""/>
				<parameter name="@Mota" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ViTri" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@SoLanXem" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_SanPhamDanhMuc]
					(
					[ID_SanPhamDanhMuc]
					,[ID_SanPhamDanhMucCha]
					,[Ten]
					,[Mota]
					,[HinhMinhHoa]
					,[TrangThai]
					,[ViTri]
					,[SoLanXem]
					,[ThoiDiemChinhSua]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDSanPhamDanhMuc
					,@IDSanPhamDanhMucCha
					,@Ten
					,@Mota
					,@HinhMinhHoa
					,@TrangThai
					,@ViTri
					,@SoLanXem
					,@ThoiDiemChinhSua
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPhamDanhMuc_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_SanPhamDanhMuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDSanPhamDanhMucCha" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault=""/>
				<parameter name="@Mota" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ViTri" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@SoLanXem" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_SanPhamDanhMuc]
				SET
					[ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc
					,[ID_SanPhamDanhMucCha] = @IDSanPhamDanhMucCha
					,[Ten] = @Ten
					,[Mota] = @Mota
					,[HinhMinhHoa] = @HinhMinhHoa
					,[TrangThai] = @TrangThai
					,[ViTri] = @ViTri
					,[SoLanXem] = @SoLanXem
					,[ThoiDiemChinhSua] = @ThoiDiemChinhSua
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_SanPhamDanhMuc] = @OriginalIDSanPhamDanhMuc 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPhamDanhMuc_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_SanPhamDanhMuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_SanPhamDanhMuc] WITH (ROWLOCK) 
				WHERE
					[ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPhamDanhMuc_GetByIDSanPhamDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_SanPhamDanhMuc table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_SanPhamDanhMuc],
					[ID_SanPhamDanhMucCha],
					[Ten],
					[Mota],
					[HinhMinhHoa],
					[TrangThai],
					[ViTri],
					[SoLanXem],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_SanPhamDanhMuc]
				WHERE
					[ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_SanPhamDanhMuc_GetByIDDiaBanFromNhaCungCapSanPhamDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_SanPhamDanhMuc].[ID_SanPhamDanhMuc]
       ,dbo.[tb_SanPhamDanhMuc].[ID_SanPhamDanhMucCha]
       ,dbo.[tb_SanPhamDanhMuc].[Ten]
       ,dbo.[tb_SanPhamDanhMuc].[Mota]
       ,dbo.[tb_SanPhamDanhMuc].[HinhMinhHoa]
       ,dbo.[tb_SanPhamDanhMuc].[TrangThai]
       ,dbo.[tb_SanPhamDanhMuc].[ViTri]
       ,dbo.[tb_SanPhamDanhMuc].[SoLanXem]
       ,dbo.[tb_SanPhamDanhMuc].[ThoiDiemChinhSua]
       ,dbo.[tb_SanPhamDanhMuc].[ThoiDiemCapNhat]
  FROM dbo.[tb_SanPhamDanhMuc]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NhaCungCapSanPhamDanhMuc] 
                WHERE dbo.[tb_NhaCungCapSanPhamDanhMuc].[ID_DiaBan] = @IDDiaBan
                  AND dbo.[tb_NhaCungCapSanPhamDanhMuc].[ID_SanPhamDanhMuc] = dbo.[tb_SanPhamDanhMuc].[ID_SanPhamDanhMuc]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPhamDanhMuc_GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_SanPhamDanhMuc].[ID_SanPhamDanhMuc]
       ,dbo.[tb_SanPhamDanhMuc].[ID_SanPhamDanhMucCha]
       ,dbo.[tb_SanPhamDanhMuc].[Ten]
       ,dbo.[tb_SanPhamDanhMuc].[Mota]
       ,dbo.[tb_SanPhamDanhMuc].[HinhMinhHoa]
       ,dbo.[tb_SanPhamDanhMuc].[TrangThai]
       ,dbo.[tb_SanPhamDanhMuc].[ViTri]
       ,dbo.[tb_SanPhamDanhMuc].[SoLanXem]
       ,dbo.[tb_SanPhamDanhMuc].[ThoiDiemChinhSua]
       ,dbo.[tb_SanPhamDanhMuc].[ThoiDiemCapNhat]
  FROM dbo.[tb_SanPhamDanhMuc]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NhaCungCapSanPhamDanhMuc] 
                WHERE dbo.[tb_NhaCungCapSanPhamDanhMuc].[ID_NhaCungCap] = @IDNhaCungCap
                  AND dbo.[tb_NhaCungCapSanPhamDanhMuc].[ID_SanPhamDanhMuc] = dbo.[tb_SanPhamDanhMuc].[ID_SanPhamDanhMuc]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPhamDanhMuc_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_SanPhamDanhMuc table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDSanPhamDanhMucCha" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault="null"/>
				<parameter name="@Mota" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@ViTri" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@SoLanXem" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_SanPhamDanhMuc]
	, [ID_SanPhamDanhMucCha]
	, [Ten]
	, [Mota]
	, [HinhMinhHoa]
	, [TrangThai]
	, [ViTri]
	, [SoLanXem]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_SanPhamDanhMuc]
    WHERE 
	 ([ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc OR @IDSanPhamDanhMuc is null)
	AND ([ID_SanPhamDanhMucCha] = @IDSanPhamDanhMucCha OR @IDSanPhamDanhMucCha is null)
	AND ([Ten] = @Ten OR @Ten is null)
	AND ([HinhMinhHoa] = @HinhMinhHoa OR @HinhMinhHoa is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
	AND ([ViTri] = @ViTri OR @ViTri is null)
	AND ([SoLanXem] = @SoLanXem OR @SoLanXem is null)
	AND ([ThoiDiemChinhSua] = @ThoiDiemChinhSua OR @ThoiDiemChinhSua is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_SanPhamDanhMuc]
	, [ID_SanPhamDanhMucCha]
	, [Ten]
	, [Mota]
	, [HinhMinhHoa]
	, [TrangThai]
	, [ViTri]
	, [SoLanXem]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_SanPhamDanhMuc]
    WHERE 
	 ([ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc AND @IDSanPhamDanhMuc is not null)
	OR ([ID_SanPhamDanhMucCha] = @IDSanPhamDanhMucCha AND @IDSanPhamDanhMucCha is not null)
	OR ([Ten] = @Ten AND @Ten is not null)
	OR ([HinhMinhHoa] = @HinhMinhHoa AND @HinhMinhHoa is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	OR ([ViTri] = @ViTri AND @ViTri is not null)
	OR ([SoLanXem] = @SoLanXem AND @SoLanXem is not null)
	OR ([ThoiDiemChinhSua] = @ThoiDiemChinhSua AND @ThoiDiemChinhSua is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_SanPhamDanhMuc_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_SanPhamDanhMuc table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_SanPhamDanhMuc]
					, [ID_SanPhamDanhMucCha]
					, [Ten]
					, [Mota]
					, [HinhMinhHoa]
					, [TrangThai]
					, [ViTri]
					, [SoLanXem]
					, [ThoiDiemChinhSua]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_SanPhamDanhMuc] {0}
				)
				select
				       [ID_SanPhamDanhMuc],
				       [ID_SanPhamDanhMucCha],
				       [Ten],
				       [Mota],
				       [HinhMinhHoa],
				       [TrangThai],
				       [ViTri],
				       [SoLanXem],
				       [ThoiDiemChinhSua],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_SanPhamDanhMuc] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_SanPham_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_SanPham table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_SanPham],
					[ID_SanPhamDanhMuc],
					[NhaCungCap],
					[Ten],
					[MoTa],
					[NhaSanXuat],
					[DonViTinh],
					[HinhMinhHoa],
					[TrangThai],
					[ViTri],
					[SoLanXem],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_SanPham]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_SanPham_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_SanPham table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_SanPham]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_SanPham]'
				SET @SQL = @SQL + ', [ID_SanPhamDanhMuc]'
				SET @SQL = @SQL + ', [NhaCungCap]'
				SET @SQL = @SQL + ', [Ten]'
				SET @SQL = @SQL + ', [MoTa]'
				SET @SQL = @SQL + ', [NhaSanXuat]'
				SET @SQL = @SQL + ', [DonViTinh]'
				SET @SQL = @SQL + ', [HinhMinhHoa]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ', [ViTri]'
				SET @SQL = @SQL + ', [SoLanXem]'
				SET @SQL = @SQL + ', [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_SanPham]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_SanPham],'
				SET @SQL = @SQL + ' [ID_SanPhamDanhMuc],'
				SET @SQL = @SQL + ' [NhaCungCap],'
				SET @SQL = @SQL + ' [Ten],'
				SET @SQL = @SQL + ' [MoTa],'
				SET @SQL = @SQL + ' [NhaSanXuat],'
				SET @SQL = @SQL + ' [DonViTinh],'
				SET @SQL = @SQL + ' [HinhMinhHoa],'
				SET @SQL = @SQL + ' [TrangThai],'
				SET @SQL = @SQL + ' [ViTri],'
				SET @SQL = @SQL + ' [SoLanXem],'
				SET @SQL = @SQL + ' [ThoiDiemChinhSua],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_SanPham]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_SanPham_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_SanPham table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault=""/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@NhaSanXuat" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@DonViTinh" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ViTri" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@SoLanXem" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_SanPham]
					(
					[ID_SanPham]
					,[ID_SanPhamDanhMuc]
					,[NhaCungCap]
					,[Ten]
					,[MoTa]
					,[NhaSanXuat]
					,[DonViTinh]
					,[HinhMinhHoa]
					,[TrangThai]
					,[ViTri]
					,[SoLanXem]
					,[ThoiDiemChinhSua]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDSanPham
					,@IDSanPhamDanhMuc
					,@NhaCungCap
					,@Ten
					,@MoTa
					,@NhaSanXuat
					,@DonViTinh
					,@HinhMinhHoa
					,@TrangThai
					,@ViTri
					,@SoLanXem
					,@ThoiDiemChinhSua
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPham_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_SanPham table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault=""/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@NhaSanXuat" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@DonViTinh" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ViTri" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@SoLanXem" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_SanPham]
				SET
					[ID_SanPham] = @IDSanPham
					,[ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc
					,[NhaCungCap] = @NhaCungCap
					,[Ten] = @Ten
					,[MoTa] = @MoTa
					,[NhaSanXuat] = @NhaSanXuat
					,[DonViTinh] = @DonViTinh
					,[HinhMinhHoa] = @HinhMinhHoa
					,[TrangThai] = @TrangThai
					,[ViTri] = @ViTri
					,[SoLanXem] = @SoLanXem
					,[ThoiDiemChinhSua] = @ThoiDiemChinhSua
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_SanPham] = @OriginalIDSanPham 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPham_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_SanPham table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_SanPham] WITH (ROWLOCK) 
				WHERE
					[ID_SanPham] = @IDSanPham
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPham_GetByIDSanPhamDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_SanPham table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_SanPham],
					[ID_SanPhamDanhMuc],
					[NhaCungCap],
					[Ten],
					[MoTa],
					[NhaSanXuat],
					[DonViTinh],
					[HinhMinhHoa],
					[TrangThai],
					[ViTri],
					[SoLanXem],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_SanPham]
				WHERE
					[ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPham_GetByNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_SanPham table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_SanPham],
					[ID_SanPhamDanhMuc],
					[NhaCungCap],
					[Ten],
					[MoTa],
					[NhaSanXuat],
					[DonViTinh],
					[HinhMinhHoa],
					[TrangThai],
					[ViTri],
					[SoLanXem],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_SanPham]
				WHERE
					[NhaCungCap] = @NhaCungCap
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_SanPham_GetByIDSanPham" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_SanPham table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_SanPham],
					[ID_SanPhamDanhMuc],
					[NhaCungCap],
					[Ten],
					[MoTa],
					[NhaSanXuat],
					[DonViTinh],
					[HinhMinhHoa],
					[TrangThai],
					[ViTri],
					[SoLanXem],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_SanPham]
				WHERE
					[ID_SanPham] = @IDSanPham
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_SanPham_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_SanPham table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault="null"/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault="null"/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@NhaSanXuat" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
				<parameter name="@DonViTinh" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@ViTri" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault="null"/>
				<parameter name="@SoLanXem" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_SanPham]
	, [ID_SanPhamDanhMuc]
	, [NhaCungCap]
	, [Ten]
	, [MoTa]
	, [NhaSanXuat]
	, [DonViTinh]
	, [HinhMinhHoa]
	, [TrangThai]
	, [ViTri]
	, [SoLanXem]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_SanPham]
    WHERE 
	 ([ID_SanPham] = @IDSanPham OR @IDSanPham is null)
	AND ([ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc OR @IDSanPhamDanhMuc is null)
	AND ([NhaCungCap] = @NhaCungCap OR @NhaCungCap is null)
	AND ([Ten] = @Ten OR @Ten is null)
	AND ([NhaSanXuat] = @NhaSanXuat OR @NhaSanXuat is null)
	AND ([DonViTinh] = @DonViTinh OR @DonViTinh is null)
	AND ([HinhMinhHoa] = @HinhMinhHoa OR @HinhMinhHoa is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
	AND ([ViTri] = @ViTri OR @ViTri is null)
	AND ([SoLanXem] = @SoLanXem OR @SoLanXem is null)
	AND ([ThoiDiemChinhSua] = @ThoiDiemChinhSua OR @ThoiDiemChinhSua is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_SanPham]
	, [ID_SanPhamDanhMuc]
	, [NhaCungCap]
	, [Ten]
	, [MoTa]
	, [NhaSanXuat]
	, [DonViTinh]
	, [HinhMinhHoa]
	, [TrangThai]
	, [ViTri]
	, [SoLanXem]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_SanPham]
    WHERE 
	 ([ID_SanPham] = @IDSanPham AND @IDSanPham is not null)
	OR ([ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc AND @IDSanPhamDanhMuc is not null)
	OR ([NhaCungCap] = @NhaCungCap AND @NhaCungCap is not null)
	OR ([Ten] = @Ten AND @Ten is not null)
	OR ([NhaSanXuat] = @NhaSanXuat AND @NhaSanXuat is not null)
	OR ([DonViTinh] = @DonViTinh AND @DonViTinh is not null)
	OR ([HinhMinhHoa] = @HinhMinhHoa AND @HinhMinhHoa is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	OR ([ViTri] = @ViTri AND @ViTri is not null)
	OR ([SoLanXem] = @SoLanXem AND @SoLanXem is not null)
	OR ([ThoiDiemChinhSua] = @ThoiDiemChinhSua AND @ThoiDiemChinhSua is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_SanPham_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_SanPham table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_SanPham]
					, [ID_SanPhamDanhMuc]
					, [NhaCungCap]
					, [Ten]
					, [MoTa]
					, [NhaSanXuat]
					, [DonViTinh]
					, [HinhMinhHoa]
					, [TrangThai]
					, [ViTri]
					, [SoLanXem]
					, [ThoiDiemChinhSua]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_SanPham] {0}
				)
				select
				       [ID_SanPham],
				       [ID_SanPhamDanhMuc],
				       [NhaCungCap],
				       [Ten],
				       [MoTa],
				       [NhaSanXuat],
				       [DonViTinh],
				       [HinhMinhHoa],
				       [TrangThai],
				       [ViTri],
				       [SoLanXem],
				       [ThoiDiemChinhSua],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_SanPham] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaCungCapSanPhamDanhMuc_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NhaCungCapSanPhamDanhMuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_DiaBan],
					[ID_NhaCungCap],
					[ID_SanPhamDanhMuc],
					[ViTri],
					[TrangThai],
					[HienThi],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NhaCungCapSanPhamDanhMuc]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaCungCapSanPhamDanhMuc_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaCungCapSanPhamDanhMuc table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_DiaBan]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_DiaBan]'
				SET @SQL = @SQL + ', [ID_NhaCungCap]'
				SET @SQL = @SQL + ', [ID_SanPhamDanhMuc]'
				SET @SQL = @SQL + ', [ViTri]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ', [HienThi]'
				SET @SQL = @SQL + ', [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaCungCapSanPhamDanhMuc]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_DiaBan],'
				SET @SQL = @SQL + ' [ID_NhaCungCap],'
				SET @SQL = @SQL + ' [ID_SanPhamDanhMuc],'
				SET @SQL = @SQL + ' [ViTri],'
				SET @SQL = @SQL + ' [TrangThai],'
				SET @SQL = @SQL + ' [HienThi],'
				SET @SQL = @SQL + ' [ThoiDiemChinhSua],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaCungCapSanPhamDanhMuc]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NhaCungCapSanPhamDanhMuc_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NhaCungCapSanPhamDanhMuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@ViTri" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@HienThi" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NhaCungCapSanPhamDanhMuc]
					(
					[ID_DiaBan]
					,[ID_NhaCungCap]
					,[ID_SanPhamDanhMuc]
					,[ViTri]
					,[TrangThai]
					,[HienThi]
					,[ThoiDiemChinhSua]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDDiaBan
					,@IDNhaCungCap
					,@IDSanPhamDanhMuc
					,@ViTri
					,@TrangThai
					,@HienThi
					,@ThoiDiemChinhSua
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapSanPhamDanhMuc_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NhaCungCapSanPhamDanhMuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@ViTri" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@HienThi" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NhaCungCapSanPhamDanhMuc]
				SET
					[ID_DiaBan] = @IDDiaBan
					,[ID_NhaCungCap] = @IDNhaCungCap
					,[ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc
					,[ViTri] = @ViTri
					,[TrangThai] = @TrangThai
					,[HienThi] = @HienThi
					,[ThoiDiemChinhSua] = @ThoiDiemChinhSua
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_DiaBan] = @OriginalIDDiaBan 
AND [ID_NhaCungCap] = @OriginalIDNhaCungCap 
AND [ID_SanPhamDanhMuc] = @OriginalIDSanPhamDanhMuc 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapSanPhamDanhMuc_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NhaCungCapSanPhamDanhMuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NhaCungCapSanPhamDanhMuc] WITH (ROWLOCK) 
				WHERE
					[ID_DiaBan] = @IDDiaBan
					AND [ID_NhaCungCap] = @IDNhaCungCap
					AND [ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapSanPhamDanhMuc_GetByIDDiaBan" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapSanPhamDanhMuc table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_DiaBan],
					[ID_NhaCungCap],
					[ID_SanPhamDanhMuc],
					[ViTri],
					[TrangThai],
					[HienThi],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NhaCungCapSanPhamDanhMuc]
				WHERE
					[ID_DiaBan] = @IDDiaBan
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapSanPhamDanhMuc_GetByIDNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapSanPhamDanhMuc table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_DiaBan],
					[ID_NhaCungCap],
					[ID_SanPhamDanhMuc],
					[ViTri],
					[TrangThai],
					[HienThi],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NhaCungCapSanPhamDanhMuc]
				WHERE
					[ID_NhaCungCap] = @IDNhaCungCap
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapSanPhamDanhMuc_GetByIDSanPhamDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapSanPhamDanhMuc table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_DiaBan],
					[ID_NhaCungCap],
					[ID_SanPhamDanhMuc],
					[ViTri],
					[TrangThai],
					[HienThi],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NhaCungCapSanPhamDanhMuc]
				WHERE
					[ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapSanPhamDanhMuc_GetByIDDiaBanIDNhaCungCapIDSanPhamDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapSanPhamDanhMuc table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_DiaBan],
					[ID_NhaCungCap],
					[ID_SanPhamDanhMuc],
					[ViTri],
					[TrangThai],
					[HienThi],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NhaCungCapSanPhamDanhMuc]
				WHERE
					[ID_DiaBan] = @IDDiaBan
					AND [ID_NhaCungCap] = @IDNhaCungCap
					AND [ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapSanPhamDanhMuc_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NhaCungCapSanPhamDanhMuc table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@ViTri" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@HienThi" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_DiaBan]
	, [ID_NhaCungCap]
	, [ID_SanPhamDanhMuc]
	, [ViTri]
	, [TrangThai]
	, [HienThi]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_NhaCungCapSanPhamDanhMuc]
    WHERE 
	 ([ID_DiaBan] = @IDDiaBan OR @IDDiaBan is null)
	AND ([ID_NhaCungCap] = @IDNhaCungCap OR @IDNhaCungCap is null)
	AND ([ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc OR @IDSanPhamDanhMuc is null)
	AND ([ViTri] = @ViTri OR @ViTri is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
	AND ([HienThi] = @HienThi OR @HienThi is null)
	AND ([ThoiDiemChinhSua] = @ThoiDiemChinhSua OR @ThoiDiemChinhSua is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_DiaBan]
	, [ID_NhaCungCap]
	, [ID_SanPhamDanhMuc]
	, [ViTri]
	, [TrangThai]
	, [HienThi]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_NhaCungCapSanPhamDanhMuc]
    WHERE 
	 ([ID_DiaBan] = @IDDiaBan AND @IDDiaBan is not null)
	OR ([ID_NhaCungCap] = @IDNhaCungCap AND @IDNhaCungCap is not null)
	OR ([ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc AND @IDSanPhamDanhMuc is not null)
	OR ([ViTri] = @ViTri AND @ViTri is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	OR ([HienThi] = @HienThi AND @HienThi is not null)
	OR ([ThoiDiemChinhSua] = @ThoiDiemChinhSua AND @ThoiDiemChinhSua is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NhaCungCapSanPhamDanhMuc_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaCungCapSanPhamDanhMuc table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_DiaBan]
					, [ID_NhaCungCap]
					, [ID_SanPhamDanhMuc]
					, [ViTri]
					, [TrangThai]
					, [HienThi]
					, [ThoiDiemChinhSua]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_NhaCungCapSanPhamDanhMuc] {0}
				)
				select
				       [ID_DiaBan],
				       [ID_NhaCungCap],
				       [ID_SanPhamDanhMuc],
				       [ViTri],
				       [TrangThai],
				       [HienThi],
				       [ThoiDiemChinhSua],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NhaCungCapSanPhamDanhMuc] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaSanXuat_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NhaSanXuat table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NhaSanXuat],
					[Ten],
					[TenVietTat],
					[MoTa],
					[TrangThai],
					[HinhMinhHoa],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NhaSanXuat]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaSanXuat_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaSanXuat table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_NhaSanXuat]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_NhaSanXuat]'
				SET @SQL = @SQL + ', [Ten]'
				SET @SQL = @SQL + ', [TenVietTat]'
				SET @SQL = @SQL + ', [MoTa]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ', [HinhMinhHoa]'
				SET @SQL = @SQL + ', [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaSanXuat]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_NhaSanXuat],'
				SET @SQL = @SQL + ' [Ten],'
				SET @SQL = @SQL + ' [TenVietTat],'
				SET @SQL = @SQL + ' [MoTa],'
				SET @SQL = @SQL + ' [TrangThai],'
				SET @SQL = @SQL + ' [HinhMinhHoa],'
				SET @SQL = @SQL + ' [ThoiDiemChinhSua],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaSanXuat]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NhaSanXuat_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NhaSanXuat table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaSanXuat" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@TenVietTat" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NhaSanXuat]
					(
					[ID_NhaSanXuat]
					,[Ten]
					,[TenVietTat]
					,[MoTa]
					,[TrangThai]
					,[HinhMinhHoa]
					,[ThoiDiemChinhSua]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDNhaSanXuat
					,@Ten
					,@TenVietTat
					,@MoTa
					,@TrangThai
					,@HinhMinhHoa
					,@ThoiDiemChinhSua
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaSanXuat_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NhaSanXuat table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaSanXuat" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNhaSanXuat" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@TenVietTat" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NhaSanXuat]
				SET
					[ID_NhaSanXuat] = @IDNhaSanXuat
					,[Ten] = @Ten
					,[TenVietTat] = @TenVietTat
					,[MoTa] = @MoTa
					,[TrangThai] = @TrangThai
					,[HinhMinhHoa] = @HinhMinhHoa
					,[ThoiDiemChinhSua] = @ThoiDiemChinhSua
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_NhaSanXuat] = @OriginalIDNhaSanXuat 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaSanXuat_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NhaSanXuat table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaSanXuat" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NhaSanXuat] WITH (ROWLOCK) 
				WHERE
					[ID_NhaSanXuat] = @IDNhaSanXuat
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaSanXuat_GetByIDNhaSanXuat" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaSanXuat table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaSanXuat" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NhaSanXuat],
					[Ten],
					[TenVietTat],
					[MoTa],
					[TrangThai],
					[HinhMinhHoa],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NhaSanXuat]
				WHERE
					[ID_NhaSanXuat] = @IDNhaSanXuat
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NhaSanXuat_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NhaSanXuat table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNhaSanXuat" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
				<parameter name="@TenVietTat" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_NhaSanXuat]
	, [Ten]
	, [TenVietTat]
	, [MoTa]
	, [TrangThai]
	, [HinhMinhHoa]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_NhaSanXuat]
    WHERE 
	 ([ID_NhaSanXuat] = @IDNhaSanXuat OR @IDNhaSanXuat is null)
	AND ([Ten] = @Ten OR @Ten is null)
	AND ([TenVietTat] = @TenVietTat OR @TenVietTat is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
	AND ([HinhMinhHoa] = @HinhMinhHoa OR @HinhMinhHoa is null)
	AND ([ThoiDiemChinhSua] = @ThoiDiemChinhSua OR @ThoiDiemChinhSua is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_NhaSanXuat]
	, [Ten]
	, [TenVietTat]
	, [MoTa]
	, [TrangThai]
	, [HinhMinhHoa]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_NhaSanXuat]
    WHERE 
	 ([ID_NhaSanXuat] = @IDNhaSanXuat AND @IDNhaSanXuat is not null)
	OR ([Ten] = @Ten AND @Ten is not null)
	OR ([TenVietTat] = @TenVietTat AND @TenVietTat is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	OR ([HinhMinhHoa] = @HinhMinhHoa AND @HinhMinhHoa is not null)
	OR ([ThoiDiemChinhSua] = @ThoiDiemChinhSua AND @ThoiDiemChinhSua is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NhaSanXuat_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaSanXuat table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_NhaSanXuat]
					, [Ten]
					, [TenVietTat]
					, [MoTa]
					, [TrangThai]
					, [HinhMinhHoa]
					, [ThoiDiemChinhSua]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_NhaSanXuat] {0}
				)
				select
				       [ID_NhaSanXuat],
				       [Ten],
				       [TenVietTat],
				       [MoTa],
				       [TrangThai],
				       [HinhMinhHoa],
				       [ThoiDiemChinhSua],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NhaSanXuat] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_QuanLyFile_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_QuanLyFile table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_QuanLyFile],
					[ID_NguoiDung],
					[ThuMucLuuTru],
					[TenFileGoc],
					[TenFileTrenServer],
					[DungLuong],
					[KieuFile],
					[TrangThai],
					[Khoa],
					[SoLanDownLoad],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_QuanLyFile]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_QuanLyFile_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_QuanLyFile table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_QuanLyFile]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_QuanLyFile]'
				SET @SQL = @SQL + ', [ID_NguoiDung]'
				SET @SQL = @SQL + ', [ThuMucLuuTru]'
				SET @SQL = @SQL + ', [TenFileGoc]'
				SET @SQL = @SQL + ', [TenFileTrenServer]'
				SET @SQL = @SQL + ', [DungLuong]'
				SET @SQL = @SQL + ', [KieuFile]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ', [Khoa]'
				SET @SQL = @SQL + ', [SoLanDownLoad]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_QuanLyFile]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_QuanLyFile],'
				SET @SQL = @SQL + ' [ID_NguoiDung],'
				SET @SQL = @SQL + ' [ThuMucLuuTru],'
				SET @SQL = @SQL + ' [TenFileGoc],'
				SET @SQL = @SQL + ' [TenFileTrenServer],'
				SET @SQL = @SQL + ' [DungLuong],'
				SET @SQL = @SQL + ' [KieuFile],'
				SET @SQL = @SQL + ' [TrangThai],'
				SET @SQL = @SQL + ' [Khoa],'
				SET @SQL = @SQL + ' [SoLanDownLoad],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_QuanLyFile]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_QuanLyFile_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_QuanLyFile table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDQuanLyFile" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@ThuMucLuuTru" type="nvarchar" direction="Input" size="2048" precision="0" scale="0" param="(2048)" nulldefault=""/>
				<parameter name="@TenFileGoc" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@TenFileTrenServer" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@DungLuong" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@KieuFile" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Khoa" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@SoLanDownLoad" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_QuanLyFile]
					(
					[ID_QuanLyFile]
					,[ID_NguoiDung]
					,[ThuMucLuuTru]
					,[TenFileGoc]
					,[TenFileTrenServer]
					,[DungLuong]
					,[KieuFile]
					,[TrangThai]
					,[Khoa]
					,[SoLanDownLoad]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDQuanLyFile
					,@IDNguoiDung
					,@ThuMucLuuTru
					,@TenFileGoc
					,@TenFileTrenServer
					,@DungLuong
					,@KieuFile
					,@TrangThai
					,@Khoa
					,@SoLanDownLoad
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_QuanLyFile_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_QuanLyFile table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDQuanLyFile" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDQuanLyFile" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@ThuMucLuuTru" type="nvarchar" direction="Input" size="2048" precision="0" scale="0" param="(2048)" nulldefault=""/>
				<parameter name="@TenFileGoc" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@TenFileTrenServer" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@DungLuong" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@KieuFile" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Khoa" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@SoLanDownLoad" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_QuanLyFile]
				SET
					[ID_QuanLyFile] = @IDQuanLyFile
					,[ID_NguoiDung] = @IDNguoiDung
					,[ThuMucLuuTru] = @ThuMucLuuTru
					,[TenFileGoc] = @TenFileGoc
					,[TenFileTrenServer] = @TenFileTrenServer
					,[DungLuong] = @DungLuong
					,[KieuFile] = @KieuFile
					,[TrangThai] = @TrangThai
					,[Khoa] = @Khoa
					,[SoLanDownLoad] = @SoLanDownLoad
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_QuanLyFile] = @OriginalIDQuanLyFile 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_QuanLyFile_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_QuanLyFile table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDQuanLyFile" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_QuanLyFile] WITH (ROWLOCK) 
				WHERE
					[ID_QuanLyFile] = @IDQuanLyFile
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_QuanLyFile_GetByIDNguoiDung" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_QuanLyFile table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_QuanLyFile],
					[ID_NguoiDung],
					[ThuMucLuuTru],
					[TenFileGoc],
					[TenFileTrenServer],
					[DungLuong],
					[KieuFile],
					[TrangThai],
					[Khoa],
					[SoLanDownLoad],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_QuanLyFile]
				WHERE
					[ID_NguoiDung] = @IDNguoiDung
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_QuanLyFile_GetByIDQuanLyFile" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_QuanLyFile table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDQuanLyFile" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_QuanLyFile],
					[ID_NguoiDung],
					[ThuMucLuuTru],
					[TenFileGoc],
					[TenFileTrenServer],
					[DungLuong],
					[KieuFile],
					[TrangThai],
					[Khoa],
					[SoLanDownLoad],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_QuanLyFile]
				WHERE
					[ID_QuanLyFile] = @IDQuanLyFile
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_QuanLyFile_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_QuanLyFile table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDQuanLyFile" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@ThuMucLuuTru" type="nvarchar" direction="Input" size="2048" precision="0" scale="0" param="(2048)" nulldefault="null"/>
				<parameter name="@TenFileGoc" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
				<parameter name="@TenFileTrenServer" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@DungLuong" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault="null"/>
				<parameter name="@KieuFile" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Khoa" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@SoLanDownLoad" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_QuanLyFile]
	, [ID_NguoiDung]
	, [ThuMucLuuTru]
	, [TenFileGoc]
	, [TenFileTrenServer]
	, [DungLuong]
	, [KieuFile]
	, [TrangThai]
	, [Khoa]
	, [SoLanDownLoad]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_QuanLyFile]
    WHERE 
	 ([ID_QuanLyFile] = @IDQuanLyFile OR @IDQuanLyFile is null)
	AND ([ID_NguoiDung] = @IDNguoiDung OR @IDNguoiDung is null)
	AND ([ThuMucLuuTru] = @ThuMucLuuTru OR @ThuMucLuuTru is null)
	AND ([TenFileGoc] = @TenFileGoc OR @TenFileGoc is null)
	AND ([TenFileTrenServer] = @TenFileTrenServer OR @TenFileTrenServer is null)
	AND ([DungLuong] = @DungLuong OR @DungLuong is null)
	AND ([KieuFile] = @KieuFile OR @KieuFile is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
	AND ([Khoa] = @Khoa OR @Khoa is null)
	AND ([SoLanDownLoad] = @SoLanDownLoad OR @SoLanDownLoad is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_QuanLyFile]
	, [ID_NguoiDung]
	, [ThuMucLuuTru]
	, [TenFileGoc]
	, [TenFileTrenServer]
	, [DungLuong]
	, [KieuFile]
	, [TrangThai]
	, [Khoa]
	, [SoLanDownLoad]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_QuanLyFile]
    WHERE 
	 ([ID_QuanLyFile] = @IDQuanLyFile AND @IDQuanLyFile is not null)
	OR ([ID_NguoiDung] = @IDNguoiDung AND @IDNguoiDung is not null)
	OR ([ThuMucLuuTru] = @ThuMucLuuTru AND @ThuMucLuuTru is not null)
	OR ([TenFileGoc] = @TenFileGoc AND @TenFileGoc is not null)
	OR ([TenFileTrenServer] = @TenFileTrenServer AND @TenFileTrenServer is not null)
	OR ([DungLuong] = @DungLuong AND @DungLuong is not null)
	OR ([KieuFile] = @KieuFile AND @KieuFile is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	OR ([Khoa] = @Khoa AND @Khoa is not null)
	OR ([SoLanDownLoad] = @SoLanDownLoad AND @SoLanDownLoad is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_QuanLyFile_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_QuanLyFile table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_QuanLyFile]
					, [ID_NguoiDung]
					, [ThuMucLuuTru]
					, [TenFileGoc]
					, [TenFileTrenServer]
					, [DungLuong]
					, [KieuFile]
					, [TrangThai]
					, [Khoa]
					, [SoLanDownLoad]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_QuanLyFile] {0}
				)
				select
				       [ID_QuanLyFile],
				       [ID_NguoiDung],
				       [ThuMucLuuTru],
				       [TenFileGoc],
				       [TenFileTrenServer],
				       [DungLuong],
				       [KieuFile],
				       [TrangThai],
				       [Khoa],
				       [SoLanDownLoad],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_QuanLyFile] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTucBinhLuan_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_TinTucBinhLuan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTucBinhLuan],
					[ID_TinTuc],
					[TenSuDung],
					[TenNguoiDung],
					[Email],
					[NoiDung],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_TinTucBinhLuan]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTucBinhLuan_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTucBinhLuan table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_TinTucBinhLuan]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_TinTucBinhLuan]'
				SET @SQL = @SQL + ', [ID_TinTuc]'
				SET @SQL = @SQL + ', [TenSuDung]'
				SET @SQL = @SQL + ', [TenNguoiDung]'
				SET @SQL = @SQL + ', [Email]'
				SET @SQL = @SQL + ', [NoiDung]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTucBinhLuan]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_TinTucBinhLuan],'
				SET @SQL = @SQL + ' [ID_TinTuc],'
				SET @SQL = @SQL + ' [TenSuDung],'
				SET @SQL = @SQL + ' [TenNguoiDung],'
				SET @SQL = @SQL + ' [Email],'
				SET @SQL = @SQL + ' [NoiDung],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTucBinhLuan]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_TinTucBinhLuan_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_TinTucBinhLuan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucBinhLuan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TenSuDung" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
				<parameter name="@TenNguoiDung" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@NoiDung" type="nvarchar" direction="Input" size="3000" precision="0" scale="0" param="(3000)" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_TinTucBinhLuan]
					(
					[ID_TinTucBinhLuan]
					,[ID_TinTuc]
					,[TenSuDung]
					,[TenNguoiDung]
					,[Email]
					,[NoiDung]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDTinTucBinhLuan
					,@IDTinTuc
					,@TenSuDung
					,@TenNguoiDung
					,@Email
					,@NoiDung
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucBinhLuan_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_TinTucBinhLuan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucBinhLuan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDTinTucBinhLuan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TenSuDung" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
				<parameter name="@TenNguoiDung" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@NoiDung" type="nvarchar" direction="Input" size="3000" precision="0" scale="0" param="(3000)" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_TinTucBinhLuan]
				SET
					[ID_TinTucBinhLuan] = @IDTinTucBinhLuan
					,[ID_TinTuc] = @IDTinTuc
					,[TenSuDung] = @TenSuDung
					,[TenNguoiDung] = @TenNguoiDung
					,[Email] = @Email
					,[NoiDung] = @NoiDung
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_TinTucBinhLuan] = @OriginalIDTinTucBinhLuan 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucBinhLuan_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_TinTucBinhLuan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucBinhLuan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_TinTucBinhLuan] WITH (ROWLOCK) 
				WHERE
					[ID_TinTucBinhLuan] = @IDTinTucBinhLuan
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucBinhLuan_GetByIDTinTuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucBinhLuan table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTucBinhLuan],
					[ID_TinTuc],
					[TenSuDung],
					[TenNguoiDung],
					[Email],
					[NoiDung],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_TinTucBinhLuan]
				WHERE
					[ID_TinTuc] = @IDTinTuc
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucBinhLuan_GetByIDTinTucBinhLuan" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucBinhLuan table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucBinhLuan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_TinTucBinhLuan],
					[ID_TinTuc],
					[TenSuDung],
					[TenNguoiDung],
					[Email],
					[NoiDung],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_TinTucBinhLuan]
				WHERE
					[ID_TinTucBinhLuan] = @IDTinTucBinhLuan
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_TinTucBinhLuan_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_TinTucBinhLuan table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTucBinhLuan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@TenSuDung" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault="null"/>
				<parameter name="@TenNguoiDung" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@NoiDung" type="nvarchar" direction="Input" size="3000" precision="0" scale="0" param="(3000)" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_TinTucBinhLuan]
	, [ID_TinTuc]
	, [TenSuDung]
	, [TenNguoiDung]
	, [Email]
	, [NoiDung]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_TinTucBinhLuan]
    WHERE 
	 ([ID_TinTucBinhLuan] = @IDTinTucBinhLuan OR @IDTinTucBinhLuan is null)
	AND ([ID_TinTuc] = @IDTinTuc OR @IDTinTuc is null)
	AND ([TenSuDung] = @TenSuDung OR @TenSuDung is null)
	AND ([TenNguoiDung] = @TenNguoiDung OR @TenNguoiDung is null)
	AND ([Email] = @Email OR @Email is null)
	AND ([NoiDung] = @NoiDung OR @NoiDung is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_TinTucBinhLuan]
	, [ID_TinTuc]
	, [TenSuDung]
	, [TenNguoiDung]
	, [Email]
	, [NoiDung]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_TinTucBinhLuan]
    WHERE 
	 ([ID_TinTucBinhLuan] = @IDTinTucBinhLuan AND @IDTinTucBinhLuan is not null)
	OR ([ID_TinTuc] = @IDTinTuc AND @IDTinTuc is not null)
	OR ([TenSuDung] = @TenSuDung AND @TenSuDung is not null)
	OR ([TenNguoiDung] = @TenNguoiDung AND @TenNguoiDung is not null)
	OR ([Email] = @Email AND @Email is not null)
	OR ([NoiDung] = @NoiDung AND @NoiDung is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_TinTucBinhLuan_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTucBinhLuan table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_TinTucBinhLuan]
					, [ID_TinTuc]
					, [TenSuDung]
					, [TenNguoiDung]
					, [Email]
					, [NoiDung]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_TinTucBinhLuan] {0}
				)
				select
				       [ID_TinTucBinhLuan],
				       [ID_TinTuc],
				       [TenSuDung],
				       [TenNguoiDung],
				       [Email],
				       [NoiDung],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_TinTucBinhLuan] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_DiaBan_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_DiaBan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_DiaBan],
					[ID_DiaBanCha],
					[MaDiaBan],
					[Ten],
					[Mota],
					[HinhMinhHoa],
					[MaVung],
					[MacDinh],
					[TrangThai]
				FROM
					[dbo].[tb_DiaBan]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_DiaBan_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_DiaBan table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_DiaBan]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_DiaBan]'
				SET @SQL = @SQL + ', [ID_DiaBanCha]'
				SET @SQL = @SQL + ', [MaDiaBan]'
				SET @SQL = @SQL + ', [Ten]'
				SET @SQL = @SQL + ', [Mota]'
				SET @SQL = @SQL + ', [HinhMinhHoa]'
				SET @SQL = @SQL + ', [MaVung]'
				SET @SQL = @SQL + ', [MacDinh]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_DiaBan]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_DiaBan],'
				SET @SQL = @SQL + ' [ID_DiaBanCha],'
				SET @SQL = @SQL + ' [MaDiaBan],'
				SET @SQL = @SQL + ' [Ten],'
				SET @SQL = @SQL + ' [Mota],'
				SET @SQL = @SQL + ' [HinhMinhHoa],'
				SET @SQL = @SQL + ' [MaVung],'
				SET @SQL = @SQL + ' [MacDinh],'
				SET @SQL = @SQL + ' [TrangThai]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_DiaBan]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_DiaBan_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_DiaBan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDDiaBanCha" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@MaDiaBan" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="100" precision="0" scale="0" param="(100)" nulldefault=""/>
				<parameter name="@Mota" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@MaVung" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@MacDinh" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_DiaBan]
					(
					[ID_DiaBan]
					,[ID_DiaBanCha]
					,[MaDiaBan]
					,[Ten]
					,[Mota]
					,[HinhMinhHoa]
					,[MaVung]
					,[MacDinh]
					,[TrangThai]
					)
				VALUES
					(
					@IDDiaBan
					,@IDDiaBanCha
					,@MaDiaBan
					,@Ten
					,@Mota
					,@HinhMinhHoa
					,@MaVung
					,@MacDinh
					,@TrangThai
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_DiaBan_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_DiaBan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDDiaBanCha" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@MaDiaBan" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="100" precision="0" scale="0" param="(100)" nulldefault=""/>
				<parameter name="@Mota" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@MaVung" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@MacDinh" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_DiaBan]
				SET
					[ID_DiaBan] = @IDDiaBan
					,[ID_DiaBanCha] = @IDDiaBanCha
					,[MaDiaBan] = @MaDiaBan
					,[Ten] = @Ten
					,[Mota] = @Mota
					,[HinhMinhHoa] = @HinhMinhHoa
					,[MaVung] = @MaVung
					,[MacDinh] = @MacDinh
					,[TrangThai] = @TrangThai
				WHERE
[ID_DiaBan] = @OriginalIDDiaBan 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_DiaBan_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_DiaBan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_DiaBan] WITH (ROWLOCK) 
				WHERE
					[ID_DiaBan] = @IDDiaBan
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_DiaBan_GetByIDDiaBan" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_DiaBan table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_DiaBan],
					[ID_DiaBanCha],
					[MaDiaBan],
					[Ten],
					[Mota],
					[HinhMinhHoa],
					[MaVung],
					[MacDinh],
					[TrangThai]
				FROM
					[dbo].[tb_DiaBan]
				WHERE
					[ID_DiaBan] = @IDDiaBan
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_DiaBan_GetByIDNhaCungCapFromNhaCungCapDiaBan" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_DiaBan].[ID_DiaBan]
       ,dbo.[tb_DiaBan].[ID_DiaBanCha]
       ,dbo.[tb_DiaBan].[MaDiaBan]
       ,dbo.[tb_DiaBan].[Ten]
       ,dbo.[tb_DiaBan].[Mota]
       ,dbo.[tb_DiaBan].[HinhMinhHoa]
       ,dbo.[tb_DiaBan].[MaVung]
       ,dbo.[tb_DiaBan].[MacDinh]
       ,dbo.[tb_DiaBan].[TrangThai]
  FROM dbo.[tb_DiaBan]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NhaCungCapDiaBan] 
                WHERE dbo.[tb_NhaCungCapDiaBan].[ID_NhaCungCap] = @IDNhaCungCap
                  AND dbo.[tb_NhaCungCapDiaBan].[ID_DiaBan] = dbo.[tb_DiaBan].[ID_DiaBan]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_DiaBan_GetByIDNhaCungCapFromNhaCungCapSanPhamDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_DiaBan].[ID_DiaBan]
       ,dbo.[tb_DiaBan].[ID_DiaBanCha]
       ,dbo.[tb_DiaBan].[MaDiaBan]
       ,dbo.[tb_DiaBan].[Ten]
       ,dbo.[tb_DiaBan].[Mota]
       ,dbo.[tb_DiaBan].[HinhMinhHoa]
       ,dbo.[tb_DiaBan].[MaVung]
       ,dbo.[tb_DiaBan].[MacDinh]
       ,dbo.[tb_DiaBan].[TrangThai]
  FROM dbo.[tb_DiaBan]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NhaCungCapSanPhamDanhMuc] 
                WHERE dbo.[tb_NhaCungCapSanPhamDanhMuc].[ID_NhaCungCap] = @IDNhaCungCap
                  AND dbo.[tb_NhaCungCapSanPhamDanhMuc].[ID_DiaBan] = dbo.[tb_DiaBan].[ID_DiaBan]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_DiaBan_GetByIDSanPhamDanhMucFromNhaCungCapSanPhamDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPhamDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_DiaBan].[ID_DiaBan]
       ,dbo.[tb_DiaBan].[ID_DiaBanCha]
       ,dbo.[tb_DiaBan].[MaDiaBan]
       ,dbo.[tb_DiaBan].[Ten]
       ,dbo.[tb_DiaBan].[Mota]
       ,dbo.[tb_DiaBan].[HinhMinhHoa]
       ,dbo.[tb_DiaBan].[MaVung]
       ,dbo.[tb_DiaBan].[MacDinh]
       ,dbo.[tb_DiaBan].[TrangThai]
  FROM dbo.[tb_DiaBan]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NhaCungCapSanPhamDanhMuc] 
                WHERE dbo.[tb_NhaCungCapSanPhamDanhMuc].[ID_SanPhamDanhMuc] = @IDSanPhamDanhMuc
                  AND dbo.[tb_NhaCungCapSanPhamDanhMuc].[ID_DiaBan] = dbo.[tb_DiaBan].[ID_DiaBan]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_DiaBan_GetByIDNguoiDungFromNguoiDungDiaBan" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_DiaBan].[ID_DiaBan]
       ,dbo.[tb_DiaBan].[ID_DiaBanCha]
       ,dbo.[tb_DiaBan].[MaDiaBan]
       ,dbo.[tb_DiaBan].[Ten]
       ,dbo.[tb_DiaBan].[Mota]
       ,dbo.[tb_DiaBan].[HinhMinhHoa]
       ,dbo.[tb_DiaBan].[MaVung]
       ,dbo.[tb_DiaBan].[MacDinh]
       ,dbo.[tb_DiaBan].[TrangThai]
  FROM dbo.[tb_DiaBan]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NguoiDungDiaBan] 
                WHERE dbo.[tb_NguoiDungDiaBan].[ID_NguoiDung] = @IDNguoiDung
                  AND dbo.[tb_NguoiDungDiaBan].[ID_DiaBan] = dbo.[tb_DiaBan].[ID_DiaBan]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_DiaBan_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_DiaBan table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDDiaBanCha" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@MaDiaBan" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="100" precision="0" scale="0" param="(100)" nulldefault="null"/>
				<parameter name="@Mota" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@MaVung" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@MacDinh" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_DiaBan]
	, [ID_DiaBanCha]
	, [MaDiaBan]
	, [Ten]
	, [Mota]
	, [HinhMinhHoa]
	, [MaVung]
	, [MacDinh]
	, [TrangThai]
    FROM
	[dbo].[tb_DiaBan]
    WHERE 
	 ([ID_DiaBan] = @IDDiaBan OR @IDDiaBan is null)
	AND ([ID_DiaBanCha] = @IDDiaBanCha OR @IDDiaBanCha is null)
	AND ([MaDiaBan] = @MaDiaBan OR @MaDiaBan is null)
	AND ([Ten] = @Ten OR @Ten is null)
	AND ([HinhMinhHoa] = @HinhMinhHoa OR @HinhMinhHoa is null)
	AND ([MaVung] = @MaVung OR @MaVung is null)
	AND ([MacDinh] = @MacDinh OR @MacDinh is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_DiaBan]
	, [ID_DiaBanCha]
	, [MaDiaBan]
	, [Ten]
	, [Mota]
	, [HinhMinhHoa]
	, [MaVung]
	, [MacDinh]
	, [TrangThai]
    FROM
	[dbo].[tb_DiaBan]
    WHERE 
	 ([ID_DiaBan] = @IDDiaBan AND @IDDiaBan is not null)
	OR ([ID_DiaBanCha] = @IDDiaBanCha AND @IDDiaBanCha is not null)
	OR ([MaDiaBan] = @MaDiaBan AND @MaDiaBan is not null)
	OR ([Ten] = @Ten AND @Ten is not null)
	OR ([HinhMinhHoa] = @HinhMinhHoa AND @HinhMinhHoa is not null)
	OR ([MaVung] = @MaVung AND @MaVung is not null)
	OR ([MacDinh] = @MacDinh AND @MacDinh is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_DiaBan_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_DiaBan table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_DiaBan]
					, [ID_DiaBanCha]
					, [MaDiaBan]
					, [Ten]
					, [Mota]
					, [HinhMinhHoa]
					, [MaVung]
					, [MacDinh]
					, [TrangThai]
					from [dbo].[tb_DiaBan] {0}
				)
				select
				       [ID_DiaBan],
				       [ID_DiaBanCha],
				       [MaDiaBan],
				       [Ten],
				       [Mota],
				       [HinhMinhHoa],
				       [MaVung],
				       [MacDinh],
				       [TrangThai]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_DiaBan] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTucTheoChuDe_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_TinTucTheoChuDe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTuc],
					[ID_TinTucChuDe]
				FROM
					[dbo].[tb_TinTucTheoChuDe]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTucTheoChuDe_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTucTheoChuDe table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_TinTuc]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_TinTuc]'
				SET @SQL = @SQL + ', [ID_TinTucChuDe]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTucTheoChuDe]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_TinTuc],'
				SET @SQL = @SQL + ' [ID_TinTucChuDe]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTucTheoChuDe]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_TinTucTheoChuDe_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_TinTucTheoChuDe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_TinTucTheoChuDe]
					(
					[ID_TinTuc]
					,[ID_TinTucChuDe]
					)
				VALUES
					(
					@IDTinTuc
					,@IDTinTucChuDe
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucTheoChuDe_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_TinTucTheoChuDe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_TinTucTheoChuDe]
				SET
					[ID_TinTuc] = @IDTinTuc
					,[ID_TinTucChuDe] = @IDTinTucChuDe
				WHERE
[ID_TinTuc] = @OriginalIDTinTuc 
AND [ID_TinTucChuDe] = @OriginalIDTinTucChuDe 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucTheoChuDe_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_TinTucTheoChuDe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_TinTucTheoChuDe] WITH (ROWLOCK) 
				WHERE
					[ID_TinTuc] = @IDTinTuc
					AND [ID_TinTucChuDe] = @IDTinTucChuDe
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucTheoChuDe_GetByIDTinTuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucTheoChuDe table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTuc],
					[ID_TinTucChuDe]
				FROM
					[dbo].[tb_TinTucTheoChuDe]
				WHERE
					[ID_TinTuc] = @IDTinTuc
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucTheoChuDe_GetByIDTinTucChuDe" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucTheoChuDe table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTuc],
					[ID_TinTucChuDe]
				FROM
					[dbo].[tb_TinTucTheoChuDe]
				WHERE
					[ID_TinTucChuDe] = @IDTinTucChuDe
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucTheoChuDe_GetByIDTinTucIDTinTucChuDe" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucTheoChuDe table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_TinTuc],
					[ID_TinTucChuDe]
				FROM
					[dbo].[tb_TinTucTheoChuDe]
				WHERE
					[ID_TinTuc] = @IDTinTuc
					AND [ID_TinTucChuDe] = @IDTinTucChuDe
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_TinTucTheoChuDe_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_TinTucTheoChuDe table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_TinTuc]
	, [ID_TinTucChuDe]
    FROM
	[dbo].[tb_TinTucTheoChuDe]
    WHERE 
	 ([ID_TinTuc] = @IDTinTuc OR @IDTinTuc is null)
	AND ([ID_TinTucChuDe] = @IDTinTucChuDe OR @IDTinTucChuDe is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_TinTuc]
	, [ID_TinTucChuDe]
    FROM
	[dbo].[tb_TinTucTheoChuDe]
    WHERE 
	 ([ID_TinTuc] = @IDTinTuc AND @IDTinTuc is not null)
	OR ([ID_TinTucChuDe] = @IDTinTucChuDe AND @IDTinTucChuDe is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_TinTucTheoChuDe_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTucTheoChuDe table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_TinTuc]
					, [ID_TinTucChuDe]
					from [dbo].[tb_TinTucTheoChuDe] {0}
				)
				select
				       [ID_TinTuc],
				       [ID_TinTucChuDe]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_TinTucTheoChuDe] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_VaiTro_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_VaiTro table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_VaiTro],
					[TenVaiTro],
					[MoTa],
					[Xem],
					[Sua],
					[Xoa],
					[Taomoi]
				FROM
					[dbo].[tb_VaiTro]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_VaiTro_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_VaiTro table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_VaiTro]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_VaiTro]'
				SET @SQL = @SQL + ', [TenVaiTro]'
				SET @SQL = @SQL + ', [MoTa]'
				SET @SQL = @SQL + ', [Xem]'
				SET @SQL = @SQL + ', [Sua]'
				SET @SQL = @SQL + ', [Xoa]'
				SET @SQL = @SQL + ', [Taomoi]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_VaiTro]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_VaiTro],'
				SET @SQL = @SQL + ' [TenVaiTro],'
				SET @SQL = @SQL + ' [MoTa],'
				SET @SQL = @SQL + ' [Xem],'
				SET @SQL = @SQL + ' [Sua],'
				SET @SQL = @SQL + ' [Xoa],'
				SET @SQL = @SQL + ' [Taomoi]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_VaiTro]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_VaiTro_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_VaiTro table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TenVaiTro" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@MoTa" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@Xem" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Sua" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Xoa" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Taomoi" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_VaiTro]
					(
					[ID_VaiTro]
					,[TenVaiTro]
					,[MoTa]
					,[Xem]
					,[Sua]
					,[Xoa]
					,[Taomoi]
					)
				VALUES
					(
					@IDVaiTro
					,@TenVaiTro
					,@MoTa
					,@Xem
					,@Sua
					,@Xoa
					,@Taomoi
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_VaiTro_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_VaiTro table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TenVaiTro" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@MoTa" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@Xem" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Sua" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Xoa" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Taomoi" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_VaiTro]
				SET
					[ID_VaiTro] = @IDVaiTro
					,[TenVaiTro] = @TenVaiTro
					,[MoTa] = @MoTa
					,[Xem] = @Xem
					,[Sua] = @Sua
					,[Xoa] = @Xoa
					,[Taomoi] = @Taomoi
				WHERE
[ID_VaiTro] = @OriginalIDVaiTro 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_VaiTro_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_VaiTro table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_VaiTro] WITH (ROWLOCK) 
				WHERE
					[ID_VaiTro] = @IDVaiTro
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_VaiTro_GetByIDVaiTro" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_VaiTro table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_VaiTro],
					[TenVaiTro],
					[MoTa],
					[Xem],
					[Sua],
					[Xoa],
					[Taomoi]
				FROM
					[dbo].[tb_VaiTro]
				WHERE
					[ID_VaiTro] = @IDVaiTro
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_VaiTro_GetByTenVaiTro" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_VaiTro table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@TenVaiTro" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_VaiTro],
					[TenVaiTro],
					[MoTa],
					[Xem],
					[Sua],
					[Xoa],
					[Taomoi]
				FROM
					[dbo].[tb_VaiTro]
				WHERE
					[TenVaiTro] = @TenVaiTro
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_VaiTro_GetByIDNguoiDungFromNguoiDungVaiTro" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_VaiTro].[ID_VaiTro]
       ,dbo.[tb_VaiTro].[TenVaiTro]
       ,dbo.[tb_VaiTro].[MoTa]
       ,dbo.[tb_VaiTro].[Xem]
       ,dbo.[tb_VaiTro].[Sua]
       ,dbo.[tb_VaiTro].[Xoa]
       ,dbo.[tb_VaiTro].[Taomoi]
  FROM dbo.[tb_VaiTro]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NguoiDungVaiTro] 
                WHERE dbo.[tb_NguoiDungVaiTro].[ID_NguoiDung] = @IDNguoiDung
                  AND dbo.[tb_NguoiDungVaiTro].[ID_VaiTro] = dbo.[tb_VaiTro].[ID_VaiTro]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_VaiTro_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_VaiTro table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@TenVaiTro" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@MoTa" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
				<parameter name="@Xem" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Sua" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Xoa" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Taomoi" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_VaiTro]
	, [TenVaiTro]
	, [MoTa]
	, [Xem]
	, [Sua]
	, [Xoa]
	, [Taomoi]
    FROM
	[dbo].[tb_VaiTro]
    WHERE 
	 ([ID_VaiTro] = @IDVaiTro OR @IDVaiTro is null)
	AND ([TenVaiTro] = @TenVaiTro OR @TenVaiTro is null)
	AND ([MoTa] = @MoTa OR @MoTa is null)
	AND ([Xem] = @Xem OR @Xem is null)
	AND ([Sua] = @Sua OR @Sua is null)
	AND ([Xoa] = @Xoa OR @Xoa is null)
	AND ([Taomoi] = @Taomoi OR @Taomoi is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_VaiTro]
	, [TenVaiTro]
	, [MoTa]
	, [Xem]
	, [Sua]
	, [Xoa]
	, [Taomoi]
    FROM
	[dbo].[tb_VaiTro]
    WHERE 
	 ([ID_VaiTro] = @IDVaiTro AND @IDVaiTro is not null)
	OR ([TenVaiTro] = @TenVaiTro AND @TenVaiTro is not null)
	OR ([MoTa] = @MoTa AND @MoTa is not null)
	OR ([Xem] = @Xem AND @Xem is not null)
	OR ([Sua] = @Sua AND @Sua is not null)
	OR ([Xoa] = @Xoa AND @Xoa is not null)
	OR ([Taomoi] = @Taomoi AND @Taomoi is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_VaiTro_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_VaiTro table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_VaiTro]
					, [TenVaiTro]
					, [MoTa]
					, [Xem]
					, [Sua]
					, [Xoa]
					, [Taomoi]
					from [dbo].[tb_VaiTro] {0}
				)
				select
				       [ID_VaiTro],
				       [TenVaiTro],
				       [MoTa],
				       [Xem],
				       [Sua],
				       [Xoa],
				       [Taomoi]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_VaiTro] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTucTieuDiem_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_TinTucTieuDiem table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTucDanhMuc],
					[ID_TinTuc]
				FROM
					[dbo].[tb_TinTucTieuDiem]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTucTieuDiem_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTucTieuDiem table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_TinTucDanhMuc]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_TinTucDanhMuc]'
				SET @SQL = @SQL + ', [ID_TinTuc]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTucTieuDiem]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_TinTucDanhMuc],'
				SET @SQL = @SQL + ' [ID_TinTuc]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTucTieuDiem]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_TinTucTieuDiem_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_TinTucTieuDiem table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_TinTucTieuDiem]
					(
					[ID_TinTucDanhMuc]
					,[ID_TinTuc]
					)
				VALUES
					(
					@IDTinTucDanhMuc
					,@IDTinTuc
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucTieuDiem_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_TinTucTieuDiem table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_TinTucTieuDiem]
				SET
					[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
					,[ID_TinTuc] = @IDTinTuc
				WHERE
[ID_TinTucDanhMuc] = @OriginalIDTinTucDanhMuc 
AND [ID_TinTuc] = @OriginalIDTinTuc 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucTieuDiem_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_TinTucTieuDiem table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_TinTucTieuDiem] WITH (ROWLOCK) 
				WHERE
					[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
					AND [ID_TinTuc] = @IDTinTuc
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucTieuDiem_GetByIDTinTuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucTieuDiem table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTucDanhMuc],
					[ID_TinTuc]
				FROM
					[dbo].[tb_TinTucTieuDiem]
				WHERE
					[ID_TinTuc] = @IDTinTuc
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucTieuDiem_GetByIDTinTucDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucTieuDiem table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTucDanhMuc],
					[ID_TinTuc]
				FROM
					[dbo].[tb_TinTucTieuDiem]
				WHERE
					[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucTieuDiem_GetByIDTinTucDanhMucIDTinTuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucTieuDiem table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_TinTucDanhMuc],
					[ID_TinTuc]
				FROM
					[dbo].[tb_TinTucTieuDiem]
				WHERE
					[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
					AND [ID_TinTuc] = @IDTinTuc
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_TinTucTieuDiem_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_TinTucTieuDiem table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_TinTucDanhMuc]
	, [ID_TinTuc]
    FROM
	[dbo].[tb_TinTucTieuDiem]
    WHERE 
	 ([ID_TinTucDanhMuc] = @IDTinTucDanhMuc OR @IDTinTucDanhMuc is null)
	AND ([ID_TinTuc] = @IDTinTuc OR @IDTinTuc is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_TinTucDanhMuc]
	, [ID_TinTuc]
    FROM
	[dbo].[tb_TinTucTieuDiem]
    WHERE 
	 ([ID_TinTucDanhMuc] = @IDTinTucDanhMuc AND @IDTinTucDanhMuc is not null)
	OR ([ID_TinTuc] = @IDTinTuc AND @IDTinTuc is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_TinTucTieuDiem_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTucTieuDiem table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_TinTucDanhMuc]
					, [ID_TinTuc]
					from [dbo].[tb_TinTucTieuDiem] {0}
				)
				select
				       [ID_TinTucDanhMuc],
				       [ID_TinTuc]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_TinTucTieuDiem] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTucDanhMuc_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_TinTucDanhMuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTucDanhMuc],
					[ID_TinTucDanhMucCha],
					[Ten],
					[SoLienKet],
					[ViTri],
					[NhaCungCap],
					[TrangThai],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_TinTucDanhMuc]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTucDanhMuc_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTucDanhMuc table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_TinTucDanhMuc]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_TinTucDanhMuc]'
				SET @SQL = @SQL + ', [ID_TinTucDanhMucCha]'
				SET @SQL = @SQL + ', [Ten]'
				SET @SQL = @SQL + ', [SoLienKet]'
				SET @SQL = @SQL + ', [ViTri]'
				SET @SQL = @SQL + ', [NhaCungCap]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ', [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTucDanhMuc]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_TinTucDanhMuc],'
				SET @SQL = @SQL + ' [ID_TinTucDanhMucCha],'
				SET @SQL = @SQL + ' [Ten],'
				SET @SQL = @SQL + ' [SoLienKet],'
				SET @SQL = @SQL + ' [ViTri],'
				SET @SQL = @SQL + ' [NhaCungCap],'
				SET @SQL = @SQL + ' [TrangThai],'
				SET @SQL = @SQL + ' [ThoiDiemChinhSua],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTucDanhMuc]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_TinTucDanhMuc_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_TinTucDanhMuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTucDanhMucCha" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault=""/>
				<parameter name="@SoLienKet" type="tinyint" direction="Input" size="1" precision="3" scale="0" param="" nulldefault=""/>
				<parameter name="@ViTri" type="tinyint" direction="Input" size="1" precision="3" scale="0" param="" nulldefault=""/>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_TinTucDanhMuc]
					(
					[ID_TinTucDanhMuc]
					,[ID_TinTucDanhMucCha]
					,[Ten]
					,[SoLienKet]
					,[ViTri]
					,[NhaCungCap]
					,[TrangThai]
					,[ThoiDiemChinhSua]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDTinTucDanhMuc
					,@IDTinTucDanhMucCha
					,@Ten
					,@SoLienKet
					,@ViTri
					,@NhaCungCap
					,@TrangThai
					,@ThoiDiemChinhSua
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucDanhMuc_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_TinTucDanhMuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTucDanhMucCha" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault=""/>
				<parameter name="@SoLienKet" type="tinyint" direction="Input" size="1" precision="3" scale="0" param="" nulldefault=""/>
				<parameter name="@ViTri" type="tinyint" direction="Input" size="1" precision="3" scale="0" param="" nulldefault=""/>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_TinTucDanhMuc]
				SET
					[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
					,[ID_TinTucDanhMucCha] = @IDTinTucDanhMucCha
					,[Ten] = @Ten
					,[SoLienKet] = @SoLienKet
					,[ViTri] = @ViTri
					,[NhaCungCap] = @NhaCungCap
					,[TrangThai] = @TrangThai
					,[ThoiDiemChinhSua] = @ThoiDiemChinhSua
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_TinTucDanhMuc] = @OriginalIDTinTucDanhMuc 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucDanhMuc_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_TinTucDanhMuc table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_TinTucDanhMuc] WITH (ROWLOCK) 
				WHERE
					[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucDanhMuc_GetByIDTinTucDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucDanhMuc table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_TinTucDanhMuc],
					[ID_TinTucDanhMucCha],
					[Ten],
					[SoLienKet],
					[ViTri],
					[NhaCungCap],
					[TrangThai],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_TinTucDanhMuc]
				WHERE
					[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_TinTucDanhMuc_GetByIDTinTucFromTinTucTieuDiem" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_TinTucDanhMuc].[ID_TinTucDanhMuc]
       ,dbo.[tb_TinTucDanhMuc].[ID_TinTucDanhMucCha]
       ,dbo.[tb_TinTucDanhMuc].[Ten]
       ,dbo.[tb_TinTucDanhMuc].[SoLienKet]
       ,dbo.[tb_TinTucDanhMuc].[ViTri]
       ,dbo.[tb_TinTucDanhMuc].[NhaCungCap]
       ,dbo.[tb_TinTucDanhMuc].[TrangThai]
       ,dbo.[tb_TinTucDanhMuc].[ThoiDiemChinhSua]
       ,dbo.[tb_TinTucDanhMuc].[ThoiDiemCapNhat]
  FROM dbo.[tb_TinTucDanhMuc]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_TinTucTieuDiem] 
                WHERE dbo.[tb_TinTucTieuDiem].[ID_TinTuc] = @IDTinTuc
                  AND dbo.[tb_TinTucTieuDiem].[ID_TinTucDanhMuc] = dbo.[tb_TinTucDanhMuc].[ID_TinTucDanhMuc]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucDanhMuc_GetByIDTinTucFromTinTucSuKien" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_TinTucDanhMuc].[ID_TinTucDanhMuc]
       ,dbo.[tb_TinTucDanhMuc].[ID_TinTucDanhMucCha]
       ,dbo.[tb_TinTucDanhMuc].[Ten]
       ,dbo.[tb_TinTucDanhMuc].[SoLienKet]
       ,dbo.[tb_TinTucDanhMuc].[ViTri]
       ,dbo.[tb_TinTucDanhMuc].[NhaCungCap]
       ,dbo.[tb_TinTucDanhMuc].[TrangThai]
       ,dbo.[tb_TinTucDanhMuc].[ThoiDiemChinhSua]
       ,dbo.[tb_TinTucDanhMuc].[ThoiDiemCapNhat]
  FROM dbo.[tb_TinTucDanhMuc]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_TinTucSuKien] 
                WHERE dbo.[tb_TinTucSuKien].[ID_TinTuc] = @IDTinTuc
                  AND dbo.[tb_TinTucSuKien].[ID_TinTucDanhMuc] = dbo.[tb_TinTucDanhMuc].[ID_TinTucDanhMuc]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucDanhMuc_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_TinTucDanhMuc table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTucDanhMucCha" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="300" precision="0" scale="0" param="(300)" nulldefault="null"/>
				<parameter name="@SoLienKet" type="tinyint" direction="Input" size="1" precision="3" scale="0" param="" nulldefault="null"/>
				<parameter name="@ViTri" type="tinyint" direction="Input" size="1" precision="3" scale="0" param="" nulldefault="null"/>
				<parameter name="@NhaCungCap" type="varchar" direction="Input" size="25" precision="0" scale="0" param="(25)" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_TinTucDanhMuc]
	, [ID_TinTucDanhMucCha]
	, [Ten]
	, [SoLienKet]
	, [ViTri]
	, [NhaCungCap]
	, [TrangThai]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_TinTucDanhMuc]
    WHERE 
	 ([ID_TinTucDanhMuc] = @IDTinTucDanhMuc OR @IDTinTucDanhMuc is null)
	AND ([ID_TinTucDanhMucCha] = @IDTinTucDanhMucCha OR @IDTinTucDanhMucCha is null)
	AND ([Ten] = @Ten OR @Ten is null)
	AND ([SoLienKet] = @SoLienKet OR @SoLienKet is null)
	AND ([ViTri] = @ViTri OR @ViTri is null)
	AND ([NhaCungCap] = @NhaCungCap OR @NhaCungCap is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
	AND ([ThoiDiemChinhSua] = @ThoiDiemChinhSua OR @ThoiDiemChinhSua is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_TinTucDanhMuc]
	, [ID_TinTucDanhMucCha]
	, [Ten]
	, [SoLienKet]
	, [ViTri]
	, [NhaCungCap]
	, [TrangThai]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_TinTucDanhMuc]
    WHERE 
	 ([ID_TinTucDanhMuc] = @IDTinTucDanhMuc AND @IDTinTucDanhMuc is not null)
	OR ([ID_TinTucDanhMucCha] = @IDTinTucDanhMucCha AND @IDTinTucDanhMucCha is not null)
	OR ([Ten] = @Ten AND @Ten is not null)
	OR ([SoLienKet] = @SoLienKet AND @SoLienKet is not null)
	OR ([ViTri] = @ViTri AND @ViTri is not null)
	OR ([NhaCungCap] = @NhaCungCap AND @NhaCungCap is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	OR ([ThoiDiemChinhSua] = @ThoiDiemChinhSua AND @ThoiDiemChinhSua is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_TinTucDanhMuc_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTucDanhMuc table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_TinTucDanhMuc]
					, [ID_TinTucDanhMucCha]
					, [Ten]
					, [SoLienKet]
					, [ViTri]
					, [NhaCungCap]
					, [TrangThai]
					, [ThoiDiemChinhSua]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_TinTucDanhMuc] {0}
				)
				select
				       [ID_TinTucDanhMuc],
				       [ID_TinTucDanhMucCha],
				       [Ten],
				       [SoLienKet],
				       [ViTri],
				       [NhaCungCap],
				       [TrangThai],
				       [ThoiDiemChinhSua],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_TinTucDanhMuc] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NgoaiTe_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NgoaiTe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NgoaiTe],
					[KyHieu],
					[Ten],
					[TyGia],
					[MacDinh],
					[TrangThai],
					[HinhMinhHoa],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NgoaiTe]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NgoaiTe_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NgoaiTe table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_NgoaiTe]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_NgoaiTe]'
				SET @SQL = @SQL + ', [KyHieu]'
				SET @SQL = @SQL + ', [Ten]'
				SET @SQL = @SQL + ', [TyGia]'
				SET @SQL = @SQL + ', [MacDinh]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ', [HinhMinhHoa]'
				SET @SQL = @SQL + ', [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NgoaiTe]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_NgoaiTe],'
				SET @SQL = @SQL + ' [KyHieu],'
				SET @SQL = @SQL + ' [Ten],'
				SET @SQL = @SQL + ' [TyGia],'
				SET @SQL = @SQL + ' [MacDinh],'
				SET @SQL = @SQL + ' [TrangThai],'
				SET @SQL = @SQL + ' [HinhMinhHoa],'
				SET @SQL = @SQL + ' [ThoiDiemChinhSua],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NgoaiTe]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NgoaiTe_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NgoaiTe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNgoaiTe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@KyHieu" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@TyGia" type="float" direction="Input" size="8" precision="53" scale="0" param="" nulldefault=""/>
				<parameter name="@MacDinh" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NgoaiTe]
					(
					[ID_NgoaiTe]
					,[KyHieu]
					,[Ten]
					,[TyGia]
					,[MacDinh]
					,[TrangThai]
					,[HinhMinhHoa]
					,[ThoiDiemChinhSua]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDNgoaiTe
					,@KyHieu
					,@Ten
					,@TyGia
					,@MacDinh
					,@TrangThai
					,@HinhMinhHoa
					,@ThoiDiemChinhSua
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NgoaiTe_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NgoaiTe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNgoaiTe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNgoaiTe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@KyHieu" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@TyGia" type="float" direction="Input" size="8" precision="53" scale="0" param="" nulldefault=""/>
				<parameter name="@MacDinh" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NgoaiTe]
				SET
					[ID_NgoaiTe] = @IDNgoaiTe
					,[KyHieu] = @KyHieu
					,[Ten] = @Ten
					,[TyGia] = @TyGia
					,[MacDinh] = @MacDinh
					,[TrangThai] = @TrangThai
					,[HinhMinhHoa] = @HinhMinhHoa
					,[ThoiDiemChinhSua] = @ThoiDiemChinhSua
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_NgoaiTe] = @OriginalIDNgoaiTe 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NgoaiTe_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NgoaiTe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNgoaiTe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NgoaiTe] WITH (ROWLOCK) 
				WHERE
					[ID_NgoaiTe] = @IDNgoaiTe
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NgoaiTe_GetByIDNgoaiTe" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NgoaiTe table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNgoaiTe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NgoaiTe],
					[KyHieu],
					[Ten],
					[TyGia],
					[MacDinh],
					[TrangThai],
					[HinhMinhHoa],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NgoaiTe]
				WHERE
					[ID_NgoaiTe] = @IDNgoaiTe
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NgoaiTe_GetByKyHieu" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NgoaiTe table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@KyHieu" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NgoaiTe],
					[KyHieu],
					[Ten],
					[TyGia],
					[MacDinh],
					[TrangThai],
					[HinhMinhHoa],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NgoaiTe]
				WHERE
					[KyHieu] = @KyHieu
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NgoaiTe_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NgoaiTe table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNgoaiTe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@KyHieu" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault="null"/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@TyGia" type="float" direction="Input" size="8" precision="53" scale="0" param="" nulldefault="null"/>
				<parameter name="@MacDinh" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_NgoaiTe]
	, [KyHieu]
	, [Ten]
	, [TyGia]
	, [MacDinh]
	, [TrangThai]
	, [HinhMinhHoa]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_NgoaiTe]
    WHERE 
	 ([ID_NgoaiTe] = @IDNgoaiTe OR @IDNgoaiTe is null)
	AND ([KyHieu] = @KyHieu OR @KyHieu is null)
	AND ([Ten] = @Ten OR @Ten is null)
	AND ([TyGia] = @TyGia OR @TyGia is null)
	AND ([MacDinh] = @MacDinh OR @MacDinh is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
	AND ([HinhMinhHoa] = @HinhMinhHoa OR @HinhMinhHoa is null)
	AND ([ThoiDiemChinhSua] = @ThoiDiemChinhSua OR @ThoiDiemChinhSua is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_NgoaiTe]
	, [KyHieu]
	, [Ten]
	, [TyGia]
	, [MacDinh]
	, [TrangThai]
	, [HinhMinhHoa]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_NgoaiTe]
    WHERE 
	 ([ID_NgoaiTe] = @IDNgoaiTe AND @IDNgoaiTe is not null)
	OR ([KyHieu] = @KyHieu AND @KyHieu is not null)
	OR ([Ten] = @Ten AND @Ten is not null)
	OR ([TyGia] = @TyGia AND @TyGia is not null)
	OR ([MacDinh] = @MacDinh AND @MacDinh is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	OR ([HinhMinhHoa] = @HinhMinhHoa AND @HinhMinhHoa is not null)
	OR ([ThoiDiemChinhSua] = @ThoiDiemChinhSua AND @ThoiDiemChinhSua is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NgoaiTe_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NgoaiTe table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_NgoaiTe]
					, [KyHieu]
					, [Ten]
					, [TyGia]
					, [MacDinh]
					, [TrangThai]
					, [HinhMinhHoa]
					, [ThoiDiemChinhSua]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_NgoaiTe] {0}
				)
				select
				       [ID_NgoaiTe],
				       [KyHieu],
				       [Ten],
				       [TyGia],
				       [MacDinh],
				       [TrangThai],
				       [HinhMinhHoa],
				       [ThoiDiemChinhSua],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NgoaiTe] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTucChuDe_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_TinTucChuDe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTucChuDe],
					[TenChuDe],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_TinTucChuDe]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTucChuDe_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTucChuDe table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_TinTucChuDe]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_TinTucChuDe]'
				SET @SQL = @SQL + ', [TenChuDe]'
				SET @SQL = @SQL + ', [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTucChuDe]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_TinTucChuDe],'
				SET @SQL = @SQL + ' [TenChuDe],'
				SET @SQL = @SQL + ' [ThoiDiemChinhSua],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTucChuDe]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_TinTucChuDe_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_TinTucChuDe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TenChuDe" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_TinTucChuDe]
					(
					[ID_TinTucChuDe]
					,[TenChuDe]
					,[ThoiDiemChinhSua]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDTinTucChuDe
					,@TenChuDe
					,@ThoiDiemChinhSua
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucChuDe_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_TinTucChuDe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TenChuDe" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_TinTucChuDe]
				SET
					[ID_TinTucChuDe] = @IDTinTucChuDe
					,[TenChuDe] = @TenChuDe
					,[ThoiDiemChinhSua] = @ThoiDiemChinhSua
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_TinTucChuDe] = @OriginalIDTinTucChuDe 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucChuDe_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_TinTucChuDe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_TinTucChuDe] WITH (ROWLOCK) 
				WHERE
					[ID_TinTucChuDe] = @IDTinTucChuDe
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucChuDe_GetByIDTinTucChuDe" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucChuDe table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_TinTucChuDe],
					[TenChuDe],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_TinTucChuDe]
				WHERE
					[ID_TinTucChuDe] = @IDTinTucChuDe
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_TinTucChuDe_GetByIDTinTucFromTinTucTheoChuDe" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_TinTucChuDe].[ID_TinTucChuDe]
       ,dbo.[tb_TinTucChuDe].[TenChuDe]
       ,dbo.[tb_TinTucChuDe].[ThoiDiemChinhSua]
       ,dbo.[tb_TinTucChuDe].[ThoiDiemCapNhat]
  FROM dbo.[tb_TinTucChuDe]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_TinTucTheoChuDe] 
                WHERE dbo.[tb_TinTucTheoChuDe].[ID_TinTuc] = @IDTinTuc
                  AND dbo.[tb_TinTucTheoChuDe].[ID_TinTucChuDe] = dbo.[tb_TinTucChuDe].[ID_TinTucChuDe]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucChuDe_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_TinTucChuDe table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTucChuDe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@TenChuDe" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_TinTucChuDe]
	, [TenChuDe]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_TinTucChuDe]
    WHERE 
	 ([ID_TinTucChuDe] = @IDTinTucChuDe OR @IDTinTucChuDe is null)
	AND ([TenChuDe] = @TenChuDe OR @TenChuDe is null)
	AND ([ThoiDiemChinhSua] = @ThoiDiemChinhSua OR @ThoiDiemChinhSua is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_TinTucChuDe]
	, [TenChuDe]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_TinTucChuDe]
    WHERE 
	 ([ID_TinTucChuDe] = @IDTinTucChuDe AND @IDTinTucChuDe is not null)
	OR ([TenChuDe] = @TenChuDe AND @TenChuDe is not null)
	OR ([ThoiDiemChinhSua] = @ThoiDiemChinhSua AND @ThoiDiemChinhSua is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_TinTucChuDe_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTucChuDe table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_TinTucChuDe]
					, [TenChuDe]
					, [ThoiDiemChinhSua]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_TinTucChuDe] {0}
				)
				select
				       [ID_TinTucChuDe],
				       [TenChuDe],
				       [ThoiDiemChinhSua],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_TinTucChuDe] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTucSuKien_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_TinTucSuKien table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTucDanhMuc],
					[ID_TinTuc]
				FROM
					[dbo].[tb_TinTucSuKien]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_TinTucSuKien_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTucSuKien table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_TinTucDanhMuc]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_TinTucDanhMuc]'
				SET @SQL = @SQL + ', [ID_TinTuc]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTucSuKien]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_TinTucDanhMuc],'
				SET @SQL = @SQL + ' [ID_TinTuc]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_TinTucSuKien]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_TinTucSuKien_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_TinTucSuKien table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_TinTucSuKien]
					(
					[ID_TinTucDanhMuc]
					,[ID_TinTuc]
					)
				VALUES
					(
					@IDTinTucDanhMuc
					,@IDTinTuc
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucSuKien_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_TinTucSuKien table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_TinTucSuKien]
				SET
					[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
					,[ID_TinTuc] = @IDTinTuc
				WHERE
[ID_TinTucDanhMuc] = @OriginalIDTinTucDanhMuc 
AND [ID_TinTuc] = @OriginalIDTinTuc 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucSuKien_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_TinTucSuKien table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_TinTucSuKien] WITH (ROWLOCK) 
				WHERE
					[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
					AND [ID_TinTuc] = @IDTinTuc
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucSuKien_GetByIDTinTuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucSuKien table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTucDanhMuc],
					[ID_TinTuc]
				FROM
					[dbo].[tb_TinTucSuKien]
				WHERE
					[ID_TinTuc] = @IDTinTuc
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucSuKien_GetByIDTinTucDanhMuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucSuKien table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_TinTucDanhMuc],
					[ID_TinTuc]
				FROM
					[dbo].[tb_TinTucSuKien]
				WHERE
					[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_TinTucSuKien_GetByIDTinTucDanhMucIDTinTuc" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_TinTucSuKien table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_TinTucDanhMuc],
					[ID_TinTuc]
				FROM
					[dbo].[tb_TinTucSuKien]
				WHERE
					[ID_TinTucDanhMuc] = @IDTinTucDanhMuc
					AND [ID_TinTuc] = @IDTinTuc
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_TinTucSuKien_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_TinTucSuKien table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTucDanhMuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDTinTuc" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_TinTucDanhMuc]
	, [ID_TinTuc]
    FROM
	[dbo].[tb_TinTucSuKien]
    WHERE 
	 ([ID_TinTucDanhMuc] = @IDTinTucDanhMuc OR @IDTinTucDanhMuc is null)
	AND ([ID_TinTuc] = @IDTinTuc OR @IDTinTuc is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_TinTucDanhMuc]
	, [ID_TinTuc]
    FROM
	[dbo].[tb_TinTucSuKien]
    WHERE 
	 ([ID_TinTucDanhMuc] = @IDTinTucDanhMuc AND @IDTinTucDanhMuc is not null)
	OR ([ID_TinTuc] = @IDTinTuc AND @IDTinTuc is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_TinTucSuKien_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_TinTucSuKien table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_TinTucDanhMuc]
					, [ID_TinTuc]
					from [dbo].[tb_TinTucSuKien] {0}
				)
				select
				       [ID_TinTucDanhMuc],
				       [ID_TinTuc]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_TinTucSuKien] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaCungCapNganhNgheKinhDoanh_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NhaCungCapNganhNgheKinhDoanh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NhaCungCap],
					[ID_NganhNgheKinhDoanh]
				FROM
					[dbo].[tb_NhaCungCapNganhNgheKinhDoanh]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaCungCapNganhNgheKinhDoanh_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaCungCapNganhNgheKinhDoanh table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_NhaCungCap]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_NhaCungCap]'
				SET @SQL = @SQL + ', [ID_NganhNgheKinhDoanh]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaCungCapNganhNgheKinhDoanh]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_NhaCungCap],'
				SET @SQL = @SQL + ' [ID_NganhNgheKinhDoanh]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaCungCapNganhNgheKinhDoanh]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NhaCungCapNganhNgheKinhDoanh_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NhaCungCapNganhNgheKinhDoanh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NhaCungCapNganhNgheKinhDoanh]
					(
					[ID_NhaCungCap]
					,[ID_NganhNgheKinhDoanh]
					)
				VALUES
					(
					@IDNhaCungCap
					,@IDNganhNgheKinhDoanh
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapNganhNgheKinhDoanh_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NhaCungCapNganhNgheKinhDoanh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NhaCungCapNganhNgheKinhDoanh]
				SET
					[ID_NhaCungCap] = @IDNhaCungCap
					,[ID_NganhNgheKinhDoanh] = @IDNganhNgheKinhDoanh
				WHERE
[ID_NhaCungCap] = @OriginalIDNhaCungCap 
AND [ID_NganhNgheKinhDoanh] = @OriginalIDNganhNgheKinhDoanh 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapNganhNgheKinhDoanh_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NhaCungCapNganhNgheKinhDoanh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NhaCungCapNganhNgheKinhDoanh] WITH (ROWLOCK) 
				WHERE
					[ID_NhaCungCap] = @IDNhaCungCap
					AND [ID_NganhNgheKinhDoanh] = @IDNganhNgheKinhDoanh
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapNganhNgheKinhDoanh_GetByIDNganhNgheKinhDoanh" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapNganhNgheKinhDoanh table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NhaCungCap],
					[ID_NganhNgheKinhDoanh]
				FROM
					[dbo].[tb_NhaCungCapNganhNgheKinhDoanh]
				WHERE
					[ID_NganhNgheKinhDoanh] = @IDNganhNgheKinhDoanh
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapNganhNgheKinhDoanh_GetByIDNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapNganhNgheKinhDoanh table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NhaCungCap],
					[ID_NganhNgheKinhDoanh]
				FROM
					[dbo].[tb_NhaCungCapNganhNgheKinhDoanh]
				WHERE
					[ID_NhaCungCap] = @IDNhaCungCap
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapNganhNgheKinhDoanh_GetByIDNhaCungCapIDNganhNgheKinhDoanh" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapNganhNgheKinhDoanh table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NhaCungCap],
					[ID_NganhNgheKinhDoanh]
				FROM
					[dbo].[tb_NhaCungCapNganhNgheKinhDoanh]
				WHERE
					[ID_NhaCungCap] = @IDNhaCungCap
					AND [ID_NganhNgheKinhDoanh] = @IDNganhNgheKinhDoanh
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapNganhNgheKinhDoanh_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NhaCungCapNganhNgheKinhDoanh table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_NhaCungCap]
	, [ID_NganhNgheKinhDoanh]
    FROM
	[dbo].[tb_NhaCungCapNganhNgheKinhDoanh]
    WHERE 
	 ([ID_NhaCungCap] = @IDNhaCungCap OR @IDNhaCungCap is null)
	AND ([ID_NganhNgheKinhDoanh] = @IDNganhNgheKinhDoanh OR @IDNganhNgheKinhDoanh is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_NhaCungCap]
	, [ID_NganhNgheKinhDoanh]
    FROM
	[dbo].[tb_NhaCungCapNganhNgheKinhDoanh]
    WHERE 
	 ([ID_NhaCungCap] = @IDNhaCungCap AND @IDNhaCungCap is not null)
	OR ([ID_NganhNgheKinhDoanh] = @IDNganhNgheKinhDoanh AND @IDNganhNgheKinhDoanh is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NhaCungCapNganhNgheKinhDoanh_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaCungCapNganhNgheKinhDoanh table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_NhaCungCap]
					, [ID_NganhNgheKinhDoanh]
					from [dbo].[tb_NhaCungCapNganhNgheKinhDoanh] {0}
				)
				select
				       [ID_NhaCungCap],
				       [ID_NganhNgheKinhDoanh]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NhaCungCapNganhNgheKinhDoanh] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NganhNgheKinhDoanh_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NganhNgheKinhDoanh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NganhNgheKinhDoanh],
					[Ten],
					[Mota],
					[TrangThai]
				FROM
					[dbo].[tb_NganhNgheKinhDoanh]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NganhNgheKinhDoanh_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NganhNgheKinhDoanh table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_NganhNgheKinhDoanh]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_NganhNgheKinhDoanh]'
				SET @SQL = @SQL + ', [Ten]'
				SET @SQL = @SQL + ', [Mota]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NganhNgheKinhDoanh]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_NganhNgheKinhDoanh],'
				SET @SQL = @SQL + ' [Ten],'
				SET @SQL = @SQL + ' [Mota],'
				SET @SQL = @SQL + ' [TrangThai]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NganhNgheKinhDoanh]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NganhNgheKinhDoanh_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NganhNgheKinhDoanh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@Mota" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NganhNgheKinhDoanh]
					(
					[ID_NganhNgheKinhDoanh]
					,[Ten]
					,[Mota]
					,[TrangThai]
					)
				VALUES
					(
					@IDNganhNgheKinhDoanh
					,@Ten
					,@Mota
					,@TrangThai
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NganhNgheKinhDoanh_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NganhNgheKinhDoanh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@Mota" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NganhNgheKinhDoanh]
				SET
					[ID_NganhNgheKinhDoanh] = @IDNganhNgheKinhDoanh
					,[Ten] = @Ten
					,[Mota] = @Mota
					,[TrangThai] = @TrangThai
				WHERE
[ID_NganhNgheKinhDoanh] = @OriginalIDNganhNgheKinhDoanh 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NganhNgheKinhDoanh_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NganhNgheKinhDoanh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NganhNgheKinhDoanh] WITH (ROWLOCK) 
				WHERE
					[ID_NganhNgheKinhDoanh] = @IDNganhNgheKinhDoanh
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NganhNgheKinhDoanh_GetByIDNganhNgheKinhDoanh" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NganhNgheKinhDoanh table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NganhNgheKinhDoanh],
					[Ten],
					[Mota],
					[TrangThai]
				FROM
					[dbo].[tb_NganhNgheKinhDoanh]
				WHERE
					[ID_NganhNgheKinhDoanh] = @IDNganhNgheKinhDoanh
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NganhNgheKinhDoanh_GetByIDNhaCungCapFromNhaCungCapNganhNgheKinhDoanh" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_NganhNgheKinhDoanh].[ID_NganhNgheKinhDoanh]
       ,dbo.[tb_NganhNgheKinhDoanh].[Ten]
       ,dbo.[tb_NganhNgheKinhDoanh].[Mota]
       ,dbo.[tb_NganhNgheKinhDoanh].[TrangThai]
  FROM dbo.[tb_NganhNgheKinhDoanh]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NhaCungCapNganhNgheKinhDoanh] 
                WHERE dbo.[tb_NhaCungCapNganhNgheKinhDoanh].[ID_NhaCungCap] = @IDNhaCungCap
                  AND dbo.[tb_NhaCungCapNganhNgheKinhDoanh].[ID_NganhNgheKinhDoanh] = dbo.[tb_NganhNgheKinhDoanh].[ID_NganhNgheKinhDoanh]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NganhNgheKinhDoanh_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NganhNgheKinhDoanh table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNganhNgheKinhDoanh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
				<parameter name="@Mota" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_NganhNgheKinhDoanh]
	, [Ten]
	, [Mota]
	, [TrangThai]
    FROM
	[dbo].[tb_NganhNgheKinhDoanh]
    WHERE 
	 ([ID_NganhNgheKinhDoanh] = @IDNganhNgheKinhDoanh OR @IDNganhNgheKinhDoanh is null)
	AND ([Ten] = @Ten OR @Ten is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_NganhNgheKinhDoanh]
	, [Ten]
	, [Mota]
	, [TrangThai]
    FROM
	[dbo].[tb_NganhNgheKinhDoanh]
    WHERE 
	 ([ID_NganhNgheKinhDoanh] = @IDNganhNgheKinhDoanh AND @IDNganhNgheKinhDoanh is not null)
	OR ([Ten] = @Ten AND @Ten is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NganhNgheKinhDoanh_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NganhNgheKinhDoanh table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_NganhNgheKinhDoanh]
					, [Ten]
					, [Mota]
					, [TrangThai]
					from [dbo].[tb_NganhNgheKinhDoanh] {0}
				)
				select
				       [ID_NganhNgheKinhDoanh],
				       [Ten],
				       [Mota],
				       [TrangThai]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NganhNgheKinhDoanh] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NgheNghiep_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NgheNghiep table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NgheNghiep],
					[Ten],
					[Mota],
					[MacDinh],
					[TrangThai]
				FROM
					[dbo].[tb_NgheNghiep]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NgheNghiep_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NgheNghiep table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_NgheNghiep]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_NgheNghiep]'
				SET @SQL = @SQL + ', [Ten]'
				SET @SQL = @SQL + ', [Mota]'
				SET @SQL = @SQL + ', [MacDinh]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NgheNghiep]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_NgheNghiep],'
				SET @SQL = @SQL + ' [Ten],'
				SET @SQL = @SQL + ' [Mota],'
				SET @SQL = @SQL + ' [MacDinh],'
				SET @SQL = @SQL + ' [TrangThai]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NgheNghiep]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NgheNghiep_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NgheNghiep table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@Mota" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@MacDinh" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NgheNghiep]
					(
					[ID_NgheNghiep]
					,[Ten]
					,[Mota]
					,[MacDinh]
					,[TrangThai]
					)
				VALUES
					(
					@IDNgheNghiep
					,@Ten
					,@Mota
					,@MacDinh
					,@TrangThai
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NgheNghiep_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NgheNghiep table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@Mota" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@MacDinh" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NgheNghiep]
				SET
					[ID_NgheNghiep] = @IDNgheNghiep
					,[Ten] = @Ten
					,[Mota] = @Mota
					,[MacDinh] = @MacDinh
					,[TrangThai] = @TrangThai
				WHERE
[ID_NgheNghiep] = @OriginalIDNgheNghiep 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NgheNghiep_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NgheNghiep table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NgheNghiep] WITH (ROWLOCK) 
				WHERE
					[ID_NgheNghiep] = @IDNgheNghiep
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NgheNghiep_GetByIDNgheNghiep" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NgheNghiep table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NgheNghiep],
					[Ten],
					[Mota],
					[MacDinh],
					[TrangThai]
				FROM
					[dbo].[tb_NgheNghiep]
				WHERE
					[ID_NgheNghiep] = @IDNgheNghiep
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NgheNghiep_GetByIDNguoiDungFromNguoiDungNgheNghiep" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_NgheNghiep].[ID_NgheNghiep]
       ,dbo.[tb_NgheNghiep].[Ten]
       ,dbo.[tb_NgheNghiep].[Mota]
       ,dbo.[tb_NgheNghiep].[MacDinh]
       ,dbo.[tb_NgheNghiep].[TrangThai]
  FROM dbo.[tb_NgheNghiep]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NguoiDungNgheNghiep] 
                WHERE dbo.[tb_NguoiDungNgheNghiep].[ID_NguoiDung] = @IDNguoiDung
                  AND dbo.[tb_NguoiDungNgheNghiep].[ID_NgheNghiep] = dbo.[tb_NgheNghiep].[ID_NgheNghiep]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NgheNghiep_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NgheNghiep table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
				<parameter name="@Mota" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@MacDinh" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_NgheNghiep]
	, [Ten]
	, [Mota]
	, [MacDinh]
	, [TrangThai]
    FROM
	[dbo].[tb_NgheNghiep]
    WHERE 
	 ([ID_NgheNghiep] = @IDNgheNghiep OR @IDNgheNghiep is null)
	AND ([Ten] = @Ten OR @Ten is null)
	AND ([MacDinh] = @MacDinh OR @MacDinh is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_NgheNghiep]
	, [Ten]
	, [Mota]
	, [MacDinh]
	, [TrangThai]
    FROM
	[dbo].[tb_NgheNghiep]
    WHERE 
	 ([ID_NgheNghiep] = @IDNgheNghiep AND @IDNgheNghiep is not null)
	OR ([Ten] = @Ten AND @Ten is not null)
	OR ([MacDinh] = @MacDinh AND @MacDinh is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NgheNghiep_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NgheNghiep table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_NgheNghiep]
					, [Ten]
					, [Mota]
					, [MacDinh]
					, [TrangThai]
					from [dbo].[tb_NgheNghiep] {0}
				)
				select
				       [ID_NgheNghiep],
				       [Ten],
				       [Mota],
				       [MacDinh],
				       [TrangThai]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NgheNghiep] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NguoiDung_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NguoiDung table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NguoiDung],
					[TenSuDung],
					[MatKhau],
					[ChungThuc],
					[MaKichHoat],
					[KichHoat],
					[CamHoatDong],
					[Xoa],
					[Ten],
					[Ho],
					[Email],
					[NgaySinh],
					[DiaChi],
					[MoTa],
					[HinhMinhHoa],
					[DienThoai],
					[Mobile],
					[MSN],
					[Yahoo],
					[Skype],
					[IP],
					[ThoiDiemTruyCap],
					[ThoiDiemThoat],
					[ThoiDiemCapNhat],
					[ThoiDiemChinhSua]
				FROM
					[dbo].[tb_NguoiDung]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NguoiDung_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NguoiDung table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_NguoiDung]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_NguoiDung]'
				SET @SQL = @SQL + ', [TenSuDung]'
				SET @SQL = @SQL + ', [MatKhau]'
				SET @SQL = @SQL + ', [ChungThuc]'
				SET @SQL = @SQL + ', [MaKichHoat]'
				SET @SQL = @SQL + ', [KichHoat]'
				SET @SQL = @SQL + ', [CamHoatDong]'
				SET @SQL = @SQL + ', [Xoa]'
				SET @SQL = @SQL + ', [Ten]'
				SET @SQL = @SQL + ', [Ho]'
				SET @SQL = @SQL + ', [Email]'
				SET @SQL = @SQL + ', [NgaySinh]'
				SET @SQL = @SQL + ', [DiaChi]'
				SET @SQL = @SQL + ', [MoTa]'
				SET @SQL = @SQL + ', [HinhMinhHoa]'
				SET @SQL = @SQL + ', [DienThoai]'
				SET @SQL = @SQL + ', [Mobile]'
				SET @SQL = @SQL + ', [MSN]'
				SET @SQL = @SQL + ', [Yahoo]'
				SET @SQL = @SQL + ', [Skype]'
				SET @SQL = @SQL + ', [IP]'
				SET @SQL = @SQL + ', [ThoiDiemTruyCap]'
				SET @SQL = @SQL + ', [ThoiDiemThoat]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ', [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NguoiDung]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_NguoiDung],'
				SET @SQL = @SQL + ' [TenSuDung],'
				SET @SQL = @SQL + ' [MatKhau],'
				SET @SQL = @SQL + ' [ChungThuc],'
				SET @SQL = @SQL + ' [MaKichHoat],'
				SET @SQL = @SQL + ' [KichHoat],'
				SET @SQL = @SQL + ' [CamHoatDong],'
				SET @SQL = @SQL + ' [Xoa],'
				SET @SQL = @SQL + ' [Ten],'
				SET @SQL = @SQL + ' [Ho],'
				SET @SQL = @SQL + ' [Email],'
				SET @SQL = @SQL + ' [NgaySinh],'
				SET @SQL = @SQL + ' [DiaChi],'
				SET @SQL = @SQL + ' [MoTa],'
				SET @SQL = @SQL + ' [HinhMinhHoa],'
				SET @SQL = @SQL + ' [DienThoai],'
				SET @SQL = @SQL + ' [Mobile],'
				SET @SQL = @SQL + ' [MSN],'
				SET @SQL = @SQL + ' [Yahoo],'
				SET @SQL = @SQL + ' [Skype],'
				SET @SQL = @SQL + ' [IP],'
				SET @SQL = @SQL + ' [ThoiDiemTruyCap],'
				SET @SQL = @SQL + ' [ThoiDiemThoat],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat],'
				SET @SQL = @SQL + ' [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NguoiDung]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NguoiDung_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NguoiDung table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TenSuDung" type="nvarchar" direction="Input" size="256" precision="0" scale="0" param="(256)" nulldefault=""/>
				<parameter name="@MatKhau" type="nvarchar" direction="Input" size="128" precision="0" scale="0" param="(128)" nulldefault=""/>
				<parameter name="@ChungThuc" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@MaKichHoat" type="varchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@KichHoat" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@CamHoatDong" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Xoa" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Ho" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@NgaySinh" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@DiaChi" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@DienThoai" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Mobile" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@MSN" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Yahoo" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Skype" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@IP" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@ThoiDiemTruyCap" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemThoat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NguoiDung]
					(
					[ID_NguoiDung]
					,[TenSuDung]
					,[MatKhau]
					,[ChungThuc]
					,[MaKichHoat]
					,[KichHoat]
					,[CamHoatDong]
					,[Xoa]
					,[Ten]
					,[Ho]
					,[Email]
					,[NgaySinh]
					,[DiaChi]
					,[MoTa]
					,[HinhMinhHoa]
					,[DienThoai]
					,[Mobile]
					,[MSN]
					,[Yahoo]
					,[Skype]
					,[IP]
					,[ThoiDiemTruyCap]
					,[ThoiDiemThoat]
					,[ThoiDiemCapNhat]
					,[ThoiDiemChinhSua]
					)
				VALUES
					(
					@IDNguoiDung
					,@TenSuDung
					,@MatKhau
					,@ChungThuc
					,@MaKichHoat
					,@KichHoat
					,@CamHoatDong
					,@Xoa
					,@Ten
					,@Ho
					,@Email
					,@NgaySinh
					,@DiaChi
					,@MoTa
					,@HinhMinhHoa
					,@DienThoai
					,@Mobile
					,@MSN
					,@Yahoo
					,@Skype
					,@IP
					,@ThoiDiemTruyCap
					,@ThoiDiemThoat
					,@ThoiDiemCapNhat
					,@ThoiDiemChinhSua
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDung_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NguoiDung table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@TenSuDung" type="nvarchar" direction="Input" size="256" precision="0" scale="0" param="(256)" nulldefault=""/>
				<parameter name="@MatKhau" type="nvarchar" direction="Input" size="128" precision="0" scale="0" param="(128)" nulldefault=""/>
				<parameter name="@ChungThuc" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@MaKichHoat" type="varchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@KichHoat" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@CamHoatDong" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Xoa" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Ho" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@NgaySinh" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@DiaChi" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@DienThoai" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Mobile" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault=""/>
				<parameter name="@MSN" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Yahoo" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Skype" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@IP" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@ThoiDiemTruyCap" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemThoat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NguoiDung]
				SET
					[ID_NguoiDung] = @IDNguoiDung
					,[TenSuDung] = @TenSuDung
					,[MatKhau] = @MatKhau
					,[ChungThuc] = @ChungThuc
					,[MaKichHoat] = @MaKichHoat
					,[KichHoat] = @KichHoat
					,[CamHoatDong] = @CamHoatDong
					,[Xoa] = @Xoa
					,[Ten] = @Ten
					,[Ho] = @Ho
					,[Email] = @Email
					,[NgaySinh] = @NgaySinh
					,[DiaChi] = @DiaChi
					,[MoTa] = @MoTa
					,[HinhMinhHoa] = @HinhMinhHoa
					,[DienThoai] = @DienThoai
					,[Mobile] = @Mobile
					,[MSN] = @MSN
					,[Yahoo] = @Yahoo
					,[Skype] = @Skype
					,[IP] = @IP
					,[ThoiDiemTruyCap] = @ThoiDiemTruyCap
					,[ThoiDiemThoat] = @ThoiDiemThoat
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
					,[ThoiDiemChinhSua] = @ThoiDiemChinhSua
				WHERE
[ID_NguoiDung] = @OriginalIDNguoiDung 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDung_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NguoiDung table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NguoiDung] WITH (ROWLOCK) 
				WHERE
					[ID_NguoiDung] = @IDNguoiDung
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDung_GetByIDNguoiDung" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDung table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NguoiDung],
					[TenSuDung],
					[MatKhau],
					[ChungThuc],
					[MaKichHoat],
					[KichHoat],
					[CamHoatDong],
					[Xoa],
					[Ten],
					[Ho],
					[Email],
					[NgaySinh],
					[DiaChi],
					[MoTa],
					[HinhMinhHoa],
					[DienThoai],
					[Mobile],
					[MSN],
					[Yahoo],
					[Skype],
					[IP],
					[ThoiDiemTruyCap],
					[ThoiDiemThoat],
					[ThoiDiemCapNhat],
					[ThoiDiemChinhSua]
				FROM
					[dbo].[tb_NguoiDung]
				WHERE
					[ID_NguoiDung] = @IDNguoiDung
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDung_GetByIDVaiTroFromNguoiDungVaiTro" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_NguoiDung].[ID_NguoiDung]
       ,dbo.[tb_NguoiDung].[TenSuDung]
       ,dbo.[tb_NguoiDung].[MatKhau]
       ,dbo.[tb_NguoiDung].[ChungThuc]
       ,dbo.[tb_NguoiDung].[MaKichHoat]
       ,dbo.[tb_NguoiDung].[KichHoat]
       ,dbo.[tb_NguoiDung].[CamHoatDong]
       ,dbo.[tb_NguoiDung].[Xoa]
       ,dbo.[tb_NguoiDung].[Ten]
       ,dbo.[tb_NguoiDung].[Ho]
       ,dbo.[tb_NguoiDung].[Email]
       ,dbo.[tb_NguoiDung].[NgaySinh]
       ,dbo.[tb_NguoiDung].[DiaChi]
       ,dbo.[tb_NguoiDung].[MoTa]
       ,dbo.[tb_NguoiDung].[HinhMinhHoa]
       ,dbo.[tb_NguoiDung].[DienThoai]
       ,dbo.[tb_NguoiDung].[Mobile]
       ,dbo.[tb_NguoiDung].[MSN]
       ,dbo.[tb_NguoiDung].[Yahoo]
       ,dbo.[tb_NguoiDung].[Skype]
       ,dbo.[tb_NguoiDung].[IP]
       ,dbo.[tb_NguoiDung].[ThoiDiemTruyCap]
       ,dbo.[tb_NguoiDung].[ThoiDiemThoat]
       ,dbo.[tb_NguoiDung].[ThoiDiemCapNhat]
       ,dbo.[tb_NguoiDung].[ThoiDiemChinhSua]
  FROM dbo.[tb_NguoiDung]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NguoiDungVaiTro] 
                WHERE dbo.[tb_NguoiDungVaiTro].[ID_VaiTro] = @IDVaiTro
                  AND dbo.[tb_NguoiDungVaiTro].[ID_NguoiDung] = dbo.[tb_NguoiDung].[ID_NguoiDung]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDung_GetByIDDiaBanFromNguoiDungDiaBan" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_NguoiDung].[ID_NguoiDung]
       ,dbo.[tb_NguoiDung].[TenSuDung]
       ,dbo.[tb_NguoiDung].[MatKhau]
       ,dbo.[tb_NguoiDung].[ChungThuc]
       ,dbo.[tb_NguoiDung].[MaKichHoat]
       ,dbo.[tb_NguoiDung].[KichHoat]
       ,dbo.[tb_NguoiDung].[CamHoatDong]
       ,dbo.[tb_NguoiDung].[Xoa]
       ,dbo.[tb_NguoiDung].[Ten]
       ,dbo.[tb_NguoiDung].[Ho]
       ,dbo.[tb_NguoiDung].[Email]
       ,dbo.[tb_NguoiDung].[NgaySinh]
       ,dbo.[tb_NguoiDung].[DiaChi]
       ,dbo.[tb_NguoiDung].[MoTa]
       ,dbo.[tb_NguoiDung].[HinhMinhHoa]
       ,dbo.[tb_NguoiDung].[DienThoai]
       ,dbo.[tb_NguoiDung].[Mobile]
       ,dbo.[tb_NguoiDung].[MSN]
       ,dbo.[tb_NguoiDung].[Yahoo]
       ,dbo.[tb_NguoiDung].[Skype]
       ,dbo.[tb_NguoiDung].[IP]
       ,dbo.[tb_NguoiDung].[ThoiDiemTruyCap]
       ,dbo.[tb_NguoiDung].[ThoiDiemThoat]
       ,dbo.[tb_NguoiDung].[ThoiDiemCapNhat]
       ,dbo.[tb_NguoiDung].[ThoiDiemChinhSua]
  FROM dbo.[tb_NguoiDung]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NguoiDungDiaBan] 
                WHERE dbo.[tb_NguoiDungDiaBan].[ID_DiaBan] = @IDDiaBan
                  AND dbo.[tb_NguoiDungDiaBan].[ID_NguoiDung] = dbo.[tb_NguoiDung].[ID_NguoiDung]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDung_GetByIDNgheNghiepFromNguoiDungNgheNghiep" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_NguoiDung].[ID_NguoiDung]
       ,dbo.[tb_NguoiDung].[TenSuDung]
       ,dbo.[tb_NguoiDung].[MatKhau]
       ,dbo.[tb_NguoiDung].[ChungThuc]
       ,dbo.[tb_NguoiDung].[MaKichHoat]
       ,dbo.[tb_NguoiDung].[KichHoat]
       ,dbo.[tb_NguoiDung].[CamHoatDong]
       ,dbo.[tb_NguoiDung].[Xoa]
       ,dbo.[tb_NguoiDung].[Ten]
       ,dbo.[tb_NguoiDung].[Ho]
       ,dbo.[tb_NguoiDung].[Email]
       ,dbo.[tb_NguoiDung].[NgaySinh]
       ,dbo.[tb_NguoiDung].[DiaChi]
       ,dbo.[tb_NguoiDung].[MoTa]
       ,dbo.[tb_NguoiDung].[HinhMinhHoa]
       ,dbo.[tb_NguoiDung].[DienThoai]
       ,dbo.[tb_NguoiDung].[Mobile]
       ,dbo.[tb_NguoiDung].[MSN]
       ,dbo.[tb_NguoiDung].[Yahoo]
       ,dbo.[tb_NguoiDung].[Skype]
       ,dbo.[tb_NguoiDung].[IP]
       ,dbo.[tb_NguoiDung].[ThoiDiemTruyCap]
       ,dbo.[tb_NguoiDung].[ThoiDiemThoat]
       ,dbo.[tb_NguoiDung].[ThoiDiemCapNhat]
       ,dbo.[tb_NguoiDung].[ThoiDiemChinhSua]
  FROM dbo.[tb_NguoiDung]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NguoiDungNgheNghiep] 
                WHERE dbo.[tb_NguoiDungNgheNghiep].[ID_NgheNghiep] = @IDNgheNghiep
                  AND dbo.[tb_NguoiDungNgheNghiep].[ID_NguoiDung] = dbo.[tb_NguoiDung].[ID_NguoiDung]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDung_GetByIDNhaCungCapFromNguoiDungNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records through a junction table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
SELECT dbo.[tb_NguoiDung].[ID_NguoiDung]
       ,dbo.[tb_NguoiDung].[TenSuDung]
       ,dbo.[tb_NguoiDung].[MatKhau]
       ,dbo.[tb_NguoiDung].[ChungThuc]
       ,dbo.[tb_NguoiDung].[MaKichHoat]
       ,dbo.[tb_NguoiDung].[KichHoat]
       ,dbo.[tb_NguoiDung].[CamHoatDong]
       ,dbo.[tb_NguoiDung].[Xoa]
       ,dbo.[tb_NguoiDung].[Ten]
       ,dbo.[tb_NguoiDung].[Ho]
       ,dbo.[tb_NguoiDung].[Email]
       ,dbo.[tb_NguoiDung].[NgaySinh]
       ,dbo.[tb_NguoiDung].[DiaChi]
       ,dbo.[tb_NguoiDung].[MoTa]
       ,dbo.[tb_NguoiDung].[HinhMinhHoa]
       ,dbo.[tb_NguoiDung].[DienThoai]
       ,dbo.[tb_NguoiDung].[Mobile]
       ,dbo.[tb_NguoiDung].[MSN]
       ,dbo.[tb_NguoiDung].[Yahoo]
       ,dbo.[tb_NguoiDung].[Skype]
       ,dbo.[tb_NguoiDung].[IP]
       ,dbo.[tb_NguoiDung].[ThoiDiemTruyCap]
       ,dbo.[tb_NguoiDung].[ThoiDiemThoat]
       ,dbo.[tb_NguoiDung].[ThoiDiemCapNhat]
       ,dbo.[tb_NguoiDung].[ThoiDiemChinhSua]
  FROM dbo.[tb_NguoiDung]
 WHERE EXISTS (SELECT 1
                 FROM dbo.[tb_NguoiDungNhaCungCap] 
                WHERE dbo.[tb_NguoiDungNhaCungCap].[ID_NhaCungCap] = @IDNhaCungCap
                  AND dbo.[tb_NguoiDungNhaCungCap].[ID_NguoiDung] = dbo.[tb_NguoiDung].[ID_NguoiDung]
                  )
				Select @@ROWCOUNT			
				]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDung_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NguoiDung table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@TenSuDung" type="nvarchar" direction="Input" size="256" precision="0" scale="0" param="(256)" nulldefault="null"/>
				<parameter name="@MatKhau" type="nvarchar" direction="Input" size="128" precision="0" scale="0" param="(128)" nulldefault="null"/>
				<parameter name="@ChungThuc" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@MaKichHoat" type="varchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@KichHoat" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@CamHoatDong" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Xoa" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Ho" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@NgaySinh" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@DiaChi" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@HinhMinhHoa" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@DienThoai" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Mobile" type="varchar" direction="Input" size="20" precision="0" scale="0" param="(20)" nulldefault="null"/>
				<parameter name="@MSN" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Yahoo" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Skype" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@IP" type="varchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@ThoiDiemTruyCap" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemThoat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_NguoiDung]
	, [TenSuDung]
	, [MatKhau]
	, [ChungThuc]
	, [MaKichHoat]
	, [KichHoat]
	, [CamHoatDong]
	, [Xoa]
	, [Ten]
	, [Ho]
	, [Email]
	, [NgaySinh]
	, [DiaChi]
	, [MoTa]
	, [HinhMinhHoa]
	, [DienThoai]
	, [Mobile]
	, [MSN]
	, [Yahoo]
	, [Skype]
	, [IP]
	, [ThoiDiemTruyCap]
	, [ThoiDiemThoat]
	, [ThoiDiemCapNhat]
	, [ThoiDiemChinhSua]
    FROM
	[dbo].[tb_NguoiDung]
    WHERE 
	 ([ID_NguoiDung] = @IDNguoiDung OR @IDNguoiDung is null)
	AND ([TenSuDung] = @TenSuDung OR @TenSuDung is null)
	AND ([MatKhau] = @MatKhau OR @MatKhau is null)
	AND ([ChungThuc] = @ChungThuc OR @ChungThuc is null)
	AND ([MaKichHoat] = @MaKichHoat OR @MaKichHoat is null)
	AND ([KichHoat] = @KichHoat OR @KichHoat is null)
	AND ([CamHoatDong] = @CamHoatDong OR @CamHoatDong is null)
	AND ([Xoa] = @Xoa OR @Xoa is null)
	AND ([Ten] = @Ten OR @Ten is null)
	AND ([Ho] = @Ho OR @Ho is null)
	AND ([Email] = @Email OR @Email is null)
	AND ([NgaySinh] = @NgaySinh OR @NgaySinh is null)
	AND ([DiaChi] = @DiaChi OR @DiaChi is null)
	AND ([HinhMinhHoa] = @HinhMinhHoa OR @HinhMinhHoa is null)
	AND ([DienThoai] = @DienThoai OR @DienThoai is null)
	AND ([Mobile] = @Mobile OR @Mobile is null)
	AND ([MSN] = @MSN OR @MSN is null)
	AND ([Yahoo] = @Yahoo OR @Yahoo is null)
	AND ([Skype] = @Skype OR @Skype is null)
	AND ([IP] = @IP OR @IP is null)
	AND ([ThoiDiemTruyCap] = @ThoiDiemTruyCap OR @ThoiDiemTruyCap is null)
	AND ([ThoiDiemThoat] = @ThoiDiemThoat OR @ThoiDiemThoat is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
	AND ([ThoiDiemChinhSua] = @ThoiDiemChinhSua OR @ThoiDiemChinhSua is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_NguoiDung]
	, [TenSuDung]
	, [MatKhau]
	, [ChungThuc]
	, [MaKichHoat]
	, [KichHoat]
	, [CamHoatDong]
	, [Xoa]
	, [Ten]
	, [Ho]
	, [Email]
	, [NgaySinh]
	, [DiaChi]
	, [MoTa]
	, [HinhMinhHoa]
	, [DienThoai]
	, [Mobile]
	, [MSN]
	, [Yahoo]
	, [Skype]
	, [IP]
	, [ThoiDiemTruyCap]
	, [ThoiDiemThoat]
	, [ThoiDiemCapNhat]
	, [ThoiDiemChinhSua]
    FROM
	[dbo].[tb_NguoiDung]
    WHERE 
	 ([ID_NguoiDung] = @IDNguoiDung AND @IDNguoiDung is not null)
	OR ([TenSuDung] = @TenSuDung AND @TenSuDung is not null)
	OR ([MatKhau] = @MatKhau AND @MatKhau is not null)
	OR ([ChungThuc] = @ChungThuc AND @ChungThuc is not null)
	OR ([MaKichHoat] = @MaKichHoat AND @MaKichHoat is not null)
	OR ([KichHoat] = @KichHoat AND @KichHoat is not null)
	OR ([CamHoatDong] = @CamHoatDong AND @CamHoatDong is not null)
	OR ([Xoa] = @Xoa AND @Xoa is not null)
	OR ([Ten] = @Ten AND @Ten is not null)
	OR ([Ho] = @Ho AND @Ho is not null)
	OR ([Email] = @Email AND @Email is not null)
	OR ([NgaySinh] = @NgaySinh AND @NgaySinh is not null)
	OR ([DiaChi] = @DiaChi AND @DiaChi is not null)
	OR ([HinhMinhHoa] = @HinhMinhHoa AND @HinhMinhHoa is not null)
	OR ([DienThoai] = @DienThoai AND @DienThoai is not null)
	OR ([Mobile] = @Mobile AND @Mobile is not null)
	OR ([MSN] = @MSN AND @MSN is not null)
	OR ([Yahoo] = @Yahoo AND @Yahoo is not null)
	OR ([Skype] = @Skype AND @Skype is not null)
	OR ([IP] = @IP AND @IP is not null)
	OR ([ThoiDiemTruyCap] = @ThoiDiemTruyCap AND @ThoiDiemTruyCap is not null)
	OR ([ThoiDiemThoat] = @ThoiDiemThoat AND @ThoiDiemThoat is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	OR ([ThoiDiemChinhSua] = @ThoiDiemChinhSua AND @ThoiDiemChinhSua is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NguoiDung_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NguoiDung table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_NguoiDung]
					, [TenSuDung]
					, [MatKhau]
					, [ChungThuc]
					, [MaKichHoat]
					, [KichHoat]
					, [CamHoatDong]
					, [Xoa]
					, [Ten]
					, [Ho]
					, [Email]
					, [NgaySinh]
					, [DiaChi]
					, [MoTa]
					, [HinhMinhHoa]
					, [DienThoai]
					, [Mobile]
					, [MSN]
					, [Yahoo]
					, [Skype]
					, [IP]
					, [ThoiDiemTruyCap]
					, [ThoiDiemThoat]
					, [ThoiDiemCapNhat]
					, [ThoiDiemChinhSua]
					from [dbo].[tb_NguoiDung] {0}
				)
				select
				       [ID_NguoiDung],
				       [TenSuDung],
				       [MatKhau],
				       [ChungThuc],
				       [MaKichHoat],
				       [KichHoat],
				       [CamHoatDong],
				       [Xoa],
				       [Ten],
				       [Ho],
				       [Email],
				       [NgaySinh],
				       [DiaChi],
				       [MoTa],
				       [HinhMinhHoa],
				       [DienThoai],
				       [Mobile],
				       [MSN],
				       [Yahoo],
				       [Skype],
				       [IP],
				       [ThoiDiemTruyCap],
				       [ThoiDiemThoat],
				       [ThoiDiemCapNhat],
				       [ThoiDiemChinhSua]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NguoiDung] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_LienHe_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_LienHe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_LienHe],
					[HoTen],
					[Email],
					[DiaChi],
					[TieuDe],
					[NoiDung],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_LienHe]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_LienHe_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_LienHe table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_LienHe]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_LienHe]'
				SET @SQL = @SQL + ', [HoTen]'
				SET @SQL = @SQL + ', [Email]'
				SET @SQL = @SQL + ', [DiaChi]'
				SET @SQL = @SQL + ', [TieuDe]'
				SET @SQL = @SQL + ', [NoiDung]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_LienHe]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_LienHe],'
				SET @SQL = @SQL + ' [HoTen],'
				SET @SQL = @SQL + ' [Email],'
				SET @SQL = @SQL + ' [DiaChi],'
				SET @SQL = @SQL + ' [TieuDe],'
				SET @SQL = @SQL + ' [NoiDung],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_LienHe]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_LienHe_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_LienHe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDLienHe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HoTen" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@DiaChi" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@TieuDe" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@NoiDung" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_LienHe]
					(
					[ID_LienHe]
					,[HoTen]
					,[Email]
					,[DiaChi]
					,[TieuDe]
					,[NoiDung]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDLienHe
					,@HoTen
					,@Email
					,@DiaChi
					,@TieuDe
					,@NoiDung
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_LienHe_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_LienHe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDLienHe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDLienHe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HoTen" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@DiaChi" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@TieuDe" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@NoiDung" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_LienHe]
				SET
					[ID_LienHe] = @IDLienHe
					,[HoTen] = @HoTen
					,[Email] = @Email
					,[DiaChi] = @DiaChi
					,[TieuDe] = @TieuDe
					,[NoiDung] = @NoiDung
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_LienHe] = @OriginalIDLienHe 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_LienHe_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_LienHe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDLienHe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_LienHe] WITH (ROWLOCK) 
				WHERE
					[ID_LienHe] = @IDLienHe
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_LienHe_GetByIDLienHe" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_LienHe table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDLienHe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_LienHe],
					[HoTen],
					[Email],
					[DiaChi],
					[TieuDe],
					[NoiDung],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_LienHe]
				WHERE
					[ID_LienHe] = @IDLienHe
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_LienHe_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_LienHe table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDLienHe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@HoTen" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@DiaChi" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
				<parameter name="@TieuDe" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@NoiDung" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_LienHe]
	, [HoTen]
	, [Email]
	, [DiaChi]
	, [TieuDe]
	, [NoiDung]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_LienHe]
    WHERE 
	 ([ID_LienHe] = @IDLienHe OR @IDLienHe is null)
	AND ([HoTen] = @HoTen OR @HoTen is null)
	AND ([Email] = @Email OR @Email is null)
	AND ([DiaChi] = @DiaChi OR @DiaChi is null)
	AND ([TieuDe] = @TieuDe OR @TieuDe is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_LienHe]
	, [HoTen]
	, [Email]
	, [DiaChi]
	, [TieuDe]
	, [NoiDung]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_LienHe]
    WHERE 
	 ([ID_LienHe] = @IDLienHe AND @IDLienHe is not null)
	OR ([HoTen] = @HoTen AND @HoTen is not null)
	OR ([Email] = @Email AND @Email is not null)
	OR ([DiaChi] = @DiaChi AND @DiaChi is not null)
	OR ([TieuDe] = @TieuDe AND @TieuDe is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_LienHe_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_LienHe table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_LienHe]
					, [HoTen]
					, [Email]
					, [DiaChi]
					, [TieuDe]
					, [NoiDung]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_LienHe] {0}
				)
				select
				       [ID_LienHe],
				       [HoTen],
				       [Email],
				       [DiaChi],
				       [TieuDe],
				       [NoiDung],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_LienHe] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_BangGiaSanPham_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_BangGiaSanPham table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_SanPham],
					[ID_NhaCungCap],
					[ID_DiaBan],
					[KichHoat],
					[ChungThuc],
					[TrangThai],
					[ChoNhapGia],
					[DonGia],
					[VAT],
					[ID_NgoaiTe],
					[SoLuongTrongKho],
					[TieuChuanKyThuat],
					[Thongtinthem],
					[ThoiDiemDangBaoGia],
					[ThoiDiemHetHieuLuc],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat],
					[KeyBangGia]
				FROM
					[dbo].[tb_BangGiaSanPham]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_BangGiaSanPham_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_BangGiaSanPham table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_SanPham]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_SanPham]'
				SET @SQL = @SQL + ', [ID_NhaCungCap]'
				SET @SQL = @SQL + ', [ID_DiaBan]'
				SET @SQL = @SQL + ', [KichHoat]'
				SET @SQL = @SQL + ', [ChungThuc]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ', [ChoNhapGia]'
				SET @SQL = @SQL + ', [DonGia]'
				SET @SQL = @SQL + ', [VAT]'
				SET @SQL = @SQL + ', [ID_NgoaiTe]'
				SET @SQL = @SQL + ', [SoLuongTrongKho]'
				SET @SQL = @SQL + ', [TieuChuanKyThuat]'
				SET @SQL = @SQL + ', [Thongtinthem]'
				SET @SQL = @SQL + ', [ThoiDiemDangBaoGia]'
				SET @SQL = @SQL + ', [ThoiDiemHetHieuLuc]'
				SET @SQL = @SQL + ', [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ', [KeyBangGia]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_BangGiaSanPham]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_SanPham],'
				SET @SQL = @SQL + ' [ID_NhaCungCap],'
				SET @SQL = @SQL + ' [ID_DiaBan],'
				SET @SQL = @SQL + ' [KichHoat],'
				SET @SQL = @SQL + ' [ChungThuc],'
				SET @SQL = @SQL + ' [TrangThai],'
				SET @SQL = @SQL + ' [ChoNhapGia],'
				SET @SQL = @SQL + ' [DonGia],'
				SET @SQL = @SQL + ' [VAT],'
				SET @SQL = @SQL + ' [ID_NgoaiTe],'
				SET @SQL = @SQL + ' [SoLuongTrongKho],'
				SET @SQL = @SQL + ' [TieuChuanKyThuat],'
				SET @SQL = @SQL + ' [Thongtinthem],'
				SET @SQL = @SQL + ' [ThoiDiemDangBaoGia],'
				SET @SQL = @SQL + ' [ThoiDiemHetHieuLuc],'
				SET @SQL = @SQL + ' [ThoiDiemChinhSua],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat],'
				SET @SQL = @SQL + ' [KeyBangGia]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_BangGiaSanPham]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_BangGiaSanPham_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_BangGiaSanPham table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@KichHoat" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ChungThuc" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ChoNhapGia" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@DonGia" type="money" direction="Input" size="8" precision="19" scale="4" param="" nulldefault=""/>
				<parameter name="@VAT" type="float" direction="Input" size="8" precision="53" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNgoaiTe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@SoLuongTrongKho" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@TieuChuanKyThuat" type="nvarchar" direction="Input" size="256" precision="0" scale="0" param="(256)" nulldefault=""/>
				<parameter name="@Thongtinthem" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemDangBaoGia" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemHetHieuLuc" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@KeyBangGia" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_BangGiaSanPham]
					(
					[ID_SanPham]
					,[ID_NhaCungCap]
					,[ID_DiaBan]
					,[KichHoat]
					,[ChungThuc]
					,[TrangThai]
					,[ChoNhapGia]
					,[DonGia]
					,[VAT]
					,[ID_NgoaiTe]
					,[SoLuongTrongKho]
					,[TieuChuanKyThuat]
					,[Thongtinthem]
					,[ThoiDiemDangBaoGia]
					,[ThoiDiemHetHieuLuc]
					,[ThoiDiemChinhSua]
					,[ThoiDiemCapNhat]
					,[KeyBangGia]
					)
				VALUES
					(
					@IDSanPham
					,@IDNhaCungCap
					,@IDDiaBan
					,@KichHoat
					,@ChungThuc
					,@TrangThai
					,@ChoNhapGia
					,@DonGia
					,@VAT
					,@IDNgoaiTe
					,@SoLuongTrongKho
					,@TieuChuanKyThuat
					,@Thongtinthem
					,@ThoiDiemDangBaoGia
					,@ThoiDiemHetHieuLuc
					,@ThoiDiemChinhSua
					,@ThoiDiemCapNhat
					,@KeyBangGia
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_BangGiaSanPham_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_BangGiaSanPham table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@KichHoat" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ChungThuc" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ChoNhapGia" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@DonGia" type="money" direction="Input" size="8" precision="19" scale="4" param="" nulldefault=""/>
				<parameter name="@VAT" type="float" direction="Input" size="8" precision="53" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNgoaiTe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@SoLuongTrongKho" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault=""/>
				<parameter name="@TieuChuanKyThuat" type="nvarchar" direction="Input" size="256" precision="0" scale="0" param="(256)" nulldefault=""/>
				<parameter name="@Thongtinthem" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemDangBaoGia" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemHetHieuLuc" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@KeyBangGia" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalKeyBangGia" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_BangGiaSanPham]
				SET
					[ID_SanPham] = @IDSanPham
					,[ID_NhaCungCap] = @IDNhaCungCap
					,[ID_DiaBan] = @IDDiaBan
					,[KichHoat] = @KichHoat
					,[ChungThuc] = @ChungThuc
					,[TrangThai] = @TrangThai
					,[ChoNhapGia] = @ChoNhapGia
					,[DonGia] = @DonGia
					,[VAT] = @VAT
					,[ID_NgoaiTe] = @IDNgoaiTe
					,[SoLuongTrongKho] = @SoLuongTrongKho
					,[TieuChuanKyThuat] = @TieuChuanKyThuat
					,[Thongtinthem] = @Thongtinthem
					,[ThoiDiemDangBaoGia] = @ThoiDiemDangBaoGia
					,[ThoiDiemHetHieuLuc] = @ThoiDiemHetHieuLuc
					,[ThoiDiemChinhSua] = @ThoiDiemChinhSua
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
					,[KeyBangGia] = @KeyBangGia
				WHERE
[KeyBangGia] = @OriginalKeyBangGia 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_BangGiaSanPham_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_BangGiaSanPham table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@KeyBangGia" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_BangGiaSanPham] WITH (ROWLOCK) 
				WHERE
					[KeyBangGia] = @KeyBangGia
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_BangGiaSanPham_GetByIDNgoaiTe" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_BangGiaSanPham table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNgoaiTe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_SanPham],
					[ID_NhaCungCap],
					[ID_DiaBan],
					[KichHoat],
					[ChungThuc],
					[TrangThai],
					[ChoNhapGia],
					[DonGia],
					[VAT],
					[ID_NgoaiTe],
					[SoLuongTrongKho],
					[TieuChuanKyThuat],
					[Thongtinthem],
					[ThoiDiemDangBaoGia],
					[ThoiDiemHetHieuLuc],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat],
					[KeyBangGia]
				FROM
					[dbo].[tb_BangGiaSanPham]
				WHERE
					[ID_NgoaiTe] = @IDNgoaiTe
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_BangGiaSanPham_GetByIDSanPham" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_BangGiaSanPham table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_SanPham],
					[ID_NhaCungCap],
					[ID_DiaBan],
					[KichHoat],
					[ChungThuc],
					[TrangThai],
					[ChoNhapGia],
					[DonGia],
					[VAT],
					[ID_NgoaiTe],
					[SoLuongTrongKho],
					[TieuChuanKyThuat],
					[Thongtinthem],
					[ThoiDiemDangBaoGia],
					[ThoiDiemHetHieuLuc],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat],
					[KeyBangGia]
				FROM
					[dbo].[tb_BangGiaSanPham]
				WHERE
					[ID_SanPham] = @IDSanPham
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_BangGiaSanPham_GetByIDDiaBan" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_BangGiaSanPham table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_SanPham],
					[ID_NhaCungCap],
					[ID_DiaBan],
					[KichHoat],
					[ChungThuc],
					[TrangThai],
					[ChoNhapGia],
					[DonGia],
					[VAT],
					[ID_NgoaiTe],
					[SoLuongTrongKho],
					[TieuChuanKyThuat],
					[Thongtinthem],
					[ThoiDiemDangBaoGia],
					[ThoiDiemHetHieuLuc],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat],
					[KeyBangGia]
				FROM
					[dbo].[tb_BangGiaSanPham]
				WHERE
					[ID_DiaBan] = @IDDiaBan
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_BangGiaSanPham_GetByIDNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_BangGiaSanPham table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_SanPham],
					[ID_NhaCungCap],
					[ID_DiaBan],
					[KichHoat],
					[ChungThuc],
					[TrangThai],
					[ChoNhapGia],
					[DonGia],
					[VAT],
					[ID_NgoaiTe],
					[SoLuongTrongKho],
					[TieuChuanKyThuat],
					[Thongtinthem],
					[ThoiDiemDangBaoGia],
					[ThoiDiemHetHieuLuc],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat],
					[KeyBangGia]
				FROM
					[dbo].[tb_BangGiaSanPham]
				WHERE
					[ID_NhaCungCap] = @IDNhaCungCap
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_BangGiaSanPham_GetByKeyBangGia" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_BangGiaSanPham table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@KeyBangGia" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_SanPham],
					[ID_NhaCungCap],
					[ID_DiaBan],
					[KichHoat],
					[ChungThuc],
					[TrangThai],
					[ChoNhapGia],
					[DonGia],
					[VAT],
					[ID_NgoaiTe],
					[SoLuongTrongKho],
					[TieuChuanKyThuat],
					[Thongtinthem],
					[ThoiDiemDangBaoGia],
					[ThoiDiemHetHieuLuc],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat],
					[KeyBangGia]
				FROM
					[dbo].[tb_BangGiaSanPham]
				WHERE
					[KeyBangGia] = @KeyBangGia
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_BangGiaSanPham_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_BangGiaSanPham table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDSanPham" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@KichHoat" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@ChungThuc" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@ChoNhapGia" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@DonGia" type="money" direction="Input" size="8" precision="19" scale="4" param="" nulldefault="null"/>
				<parameter name="@VAT" type="float" direction="Input" size="8" precision="53" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNgoaiTe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@SoLuongTrongKho" type="bigint" direction="Input" size="8" precision="19" scale="0" param="" nulldefault="null"/>
				<parameter name="@TieuChuanKyThuat" type="nvarchar" direction="Input" size="256" precision="0" scale="0" param="(256)" nulldefault="null"/>
				<parameter name="@Thongtinthem" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemDangBaoGia" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemHetHieuLuc" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@KeyBangGia" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_SanPham]
	, [ID_NhaCungCap]
	, [ID_DiaBan]
	, [KichHoat]
	, [ChungThuc]
	, [TrangThai]
	, [ChoNhapGia]
	, [DonGia]
	, [VAT]
	, [ID_NgoaiTe]
	, [SoLuongTrongKho]
	, [TieuChuanKyThuat]
	, [Thongtinthem]
	, [ThoiDiemDangBaoGia]
	, [ThoiDiemHetHieuLuc]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
	, [KeyBangGia]
    FROM
	[dbo].[tb_BangGiaSanPham]
    WHERE 
	 ([ID_SanPham] = @IDSanPham OR @IDSanPham is null)
	AND ([ID_NhaCungCap] = @IDNhaCungCap OR @IDNhaCungCap is null)
	AND ([ID_DiaBan] = @IDDiaBan OR @IDDiaBan is null)
	AND ([KichHoat] = @KichHoat OR @KichHoat is null)
	AND ([ChungThuc] = @ChungThuc OR @ChungThuc is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
	AND ([ChoNhapGia] = @ChoNhapGia OR @ChoNhapGia is null)
	AND ([DonGia] = @DonGia OR @DonGia is null)
	AND ([VAT] = @VAT OR @VAT is null)
	AND ([ID_NgoaiTe] = @IDNgoaiTe OR @IDNgoaiTe is null)
	AND ([SoLuongTrongKho] = @SoLuongTrongKho OR @SoLuongTrongKho is null)
	AND ([TieuChuanKyThuat] = @TieuChuanKyThuat OR @TieuChuanKyThuat is null)
	AND ([ThoiDiemDangBaoGia] = @ThoiDiemDangBaoGia OR @ThoiDiemDangBaoGia is null)
	AND ([ThoiDiemHetHieuLuc] = @ThoiDiemHetHieuLuc OR @ThoiDiemHetHieuLuc is null)
	AND ([ThoiDiemChinhSua] = @ThoiDiemChinhSua OR @ThoiDiemChinhSua is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
	AND ([KeyBangGia] = @KeyBangGia OR @KeyBangGia is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_SanPham]
	, [ID_NhaCungCap]
	, [ID_DiaBan]
	, [KichHoat]
	, [ChungThuc]
	, [TrangThai]
	, [ChoNhapGia]
	, [DonGia]
	, [VAT]
	, [ID_NgoaiTe]
	, [SoLuongTrongKho]
	, [TieuChuanKyThuat]
	, [Thongtinthem]
	, [ThoiDiemDangBaoGia]
	, [ThoiDiemHetHieuLuc]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
	, [KeyBangGia]
    FROM
	[dbo].[tb_BangGiaSanPham]
    WHERE 
	 ([ID_SanPham] = @IDSanPham AND @IDSanPham is not null)
	OR ([ID_NhaCungCap] = @IDNhaCungCap AND @IDNhaCungCap is not null)
	OR ([ID_DiaBan] = @IDDiaBan AND @IDDiaBan is not null)
	OR ([KichHoat] = @KichHoat AND @KichHoat is not null)
	OR ([ChungThuc] = @ChungThuc AND @ChungThuc is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	OR ([ChoNhapGia] = @ChoNhapGia AND @ChoNhapGia is not null)
	OR ([DonGia] = @DonGia AND @DonGia is not null)
	OR ([VAT] = @VAT AND @VAT is not null)
	OR ([ID_NgoaiTe] = @IDNgoaiTe AND @IDNgoaiTe is not null)
	OR ([SoLuongTrongKho] = @SoLuongTrongKho AND @SoLuongTrongKho is not null)
	OR ([TieuChuanKyThuat] = @TieuChuanKyThuat AND @TieuChuanKyThuat is not null)
	OR ([ThoiDiemDangBaoGia] = @ThoiDiemDangBaoGia AND @ThoiDiemDangBaoGia is not null)
	OR ([ThoiDiemHetHieuLuc] = @ThoiDiemHetHieuLuc AND @ThoiDiemHetHieuLuc is not null)
	OR ([ThoiDiemChinhSua] = @ThoiDiemChinhSua AND @ThoiDiemChinhSua is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	OR ([KeyBangGia] = @KeyBangGia AND @KeyBangGia is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_BangGiaSanPham_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_BangGiaSanPham table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_SanPham]
					, [ID_NhaCungCap]
					, [ID_DiaBan]
					, [KichHoat]
					, [ChungThuc]
					, [TrangThai]
					, [ChoNhapGia]
					, [DonGia]
					, [VAT]
					, [ID_NgoaiTe]
					, [SoLuongTrongKho]
					, [TieuChuanKyThuat]
					, [Thongtinthem]
					, [ThoiDiemDangBaoGia]
					, [ThoiDiemHetHieuLuc]
					, [ThoiDiemChinhSua]
					, [ThoiDiemCapNhat]
					, [KeyBangGia]
					from [dbo].[tb_BangGiaSanPham] {0}
				)
				select
				       [ID_SanPham],
				       [ID_NhaCungCap],
				       [ID_DiaBan],
				       [KichHoat],
				       [ChungThuc],
				       [TrangThai],
				       [ChoNhapGia],
				       [DonGia],
				       [VAT],
				       [ID_NgoaiTe],
				       [SoLuongTrongKho],
				       [TieuChuanKyThuat],
				       [Thongtinthem],
				       [ThoiDiemDangBaoGia],
				       [ThoiDiemHetHieuLuc],
				       [ThoiDiemChinhSua],
				       [ThoiDiemCapNhat],
				       [KeyBangGia]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_BangGiaSanPham] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_CauHinhHeThong_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_CauHinhHeThong table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_CauHinhHeThong],
					[Ten],
					[GiaTri],
					[MoTa]
				FROM
					[dbo].[tb_CauHinhHeThong]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_CauHinhHeThong_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_CauHinhHeThong table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_CauHinhHeThong]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_CauHinhHeThong]'
				SET @SQL = @SQL + ', [Ten]'
				SET @SQL = @SQL + ', [GiaTri]'
				SET @SQL = @SQL + ', [MoTa]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_CauHinhHeThong]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_CauHinhHeThong],'
				SET @SQL = @SQL + ' [Ten],'
				SET @SQL = @SQL + ' [GiaTri],'
				SET @SQL = @SQL + ' [MoTa]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_CauHinhHeThong]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_CauHinhHeThong_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_CauHinhHeThong table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDCauHinhHeThong" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@GiaTri" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_CauHinhHeThong]
					(
					[ID_CauHinhHeThong]
					,[Ten]
					,[GiaTri]
					,[MoTa]
					)
				VALUES
					(
					@IDCauHinhHeThong
					,@Ten
					,@GiaTri
					,@MoTa
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_CauHinhHeThong_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_CauHinhHeThong table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDCauHinhHeThong" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDCauHinhHeThong" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@GiaTri" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_CauHinhHeThong]
				SET
					[ID_CauHinhHeThong] = @IDCauHinhHeThong
					,[Ten] = @Ten
					,[GiaTri] = @GiaTri
					,[MoTa] = @MoTa
				WHERE
[ID_CauHinhHeThong] = @OriginalIDCauHinhHeThong 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_CauHinhHeThong_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_CauHinhHeThong table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDCauHinhHeThong" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_CauHinhHeThong] WITH (ROWLOCK) 
				WHERE
					[ID_CauHinhHeThong] = @IDCauHinhHeThong
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_CauHinhHeThong_GetByIDCauHinhHeThong" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_CauHinhHeThong table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDCauHinhHeThong" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_CauHinhHeThong],
					[Ten],
					[GiaTri],
					[MoTa]
				FROM
					[dbo].[tb_CauHinhHeThong]
				WHERE
					[ID_CauHinhHeThong] = @IDCauHinhHeThong
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_CauHinhHeThong_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_CauHinhHeThong table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDCauHinhHeThong" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@Ten" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@GiaTri" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_CauHinhHeThong]
	, [Ten]
	, [GiaTri]
	, [MoTa]
    FROM
	[dbo].[tb_CauHinhHeThong]
    WHERE 
	 ([ID_CauHinhHeThong] = @IDCauHinhHeThong OR @IDCauHinhHeThong is null)
	AND ([Ten] = @Ten OR @Ten is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_CauHinhHeThong]
	, [Ten]
	, [GiaTri]
	, [MoTa]
    FROM
	[dbo].[tb_CauHinhHeThong]
    WHERE 
	 ([ID_CauHinhHeThong] = @IDCauHinhHeThong AND @IDCauHinhHeThong is not null)
	OR ([Ten] = @Ten AND @Ten is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_CauHinhHeThong_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_CauHinhHeThong table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_CauHinhHeThong]
					, [Ten]
					, [GiaTri]
					, [MoTa]
					from [dbo].[tb_CauHinhHeThong] {0}
				)
				select
				       [ID_CauHinhHeThong],
				       [Ten],
				       [GiaTri],
				       [MoTa]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_CauHinhHeThong] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_DonViTinh_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_DonViTinh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_DonViTinh],
					[KyHieu],
					[MoTa],
					[MacDinh],
					[TrangThai],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_DonViTinh]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_DonViTinh_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_DonViTinh table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_DonViTinh]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_DonViTinh]'
				SET @SQL = @SQL + ', [KyHieu]'
				SET @SQL = @SQL + ', [MoTa]'
				SET @SQL = @SQL + ', [MacDinh]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ', [ThoiDiemChinhSua]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_DonViTinh]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_DonViTinh],'
				SET @SQL = @SQL + ' [KyHieu],'
				SET @SQL = @SQL + ' [MoTa],'
				SET @SQL = @SQL + ' [MacDinh],'
				SET @SQL = @SQL + ' [TrangThai],'
				SET @SQL = @SQL + ' [ThoiDiemChinhSua],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_DonViTinh]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_DonViTinh_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_DonViTinh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDonViTinh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@KyHieu" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@MacDinh" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_DonViTinh]
					(
					[ID_DonViTinh]
					,[KyHieu]
					,[MoTa]
					,[MacDinh]
					,[TrangThai]
					,[ThoiDiemChinhSua]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDDonViTinh
					,@KyHieu
					,@MoTa
					,@MacDinh
					,@TrangThai
					,@ThoiDiemChinhSua
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_DonViTinh_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_DonViTinh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDonViTinh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDDonViTinh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@KyHieu" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@MacDinh" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_DonViTinh]
				SET
					[ID_DonViTinh] = @IDDonViTinh
					,[KyHieu] = @KyHieu
					,[MoTa] = @MoTa
					,[MacDinh] = @MacDinh
					,[TrangThai] = @TrangThai
					,[ThoiDiemChinhSua] = @ThoiDiemChinhSua
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_DonViTinh] = @OriginalIDDonViTinh 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_DonViTinh_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_DonViTinh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDonViTinh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_DonViTinh] WITH (ROWLOCK) 
				WHERE
					[ID_DonViTinh] = @IDDonViTinh
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_DonViTinh_GetByIDDonViTinh" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_DonViTinh table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDonViTinh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_DonViTinh],
					[KyHieu],
					[MoTa],
					[MacDinh],
					[TrangThai],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_DonViTinh]
				WHERE
					[ID_DonViTinh] = @IDDonViTinh
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_DonViTinh_GetByKyHieu" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_DonViTinh table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@KyHieu" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_DonViTinh],
					[KyHieu],
					[MoTa],
					[MacDinh],
					[TrangThai],
					[ThoiDiemChinhSua],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_DonViTinh]
				WHERE
					[KyHieu] = @KyHieu
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_DonViTinh_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_DonViTinh table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDDonViTinh" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@KyHieu" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@MoTa" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@MacDinh" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemChinhSua" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_DonViTinh]
	, [KyHieu]
	, [MoTa]
	, [MacDinh]
	, [TrangThai]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_DonViTinh]
    WHERE 
	 ([ID_DonViTinh] = @IDDonViTinh OR @IDDonViTinh is null)
	AND ([KyHieu] = @KyHieu OR @KyHieu is null)
	AND ([MacDinh] = @MacDinh OR @MacDinh is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
	AND ([ThoiDiemChinhSua] = @ThoiDiemChinhSua OR @ThoiDiemChinhSua is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_DonViTinh]
	, [KyHieu]
	, [MoTa]
	, [MacDinh]
	, [TrangThai]
	, [ThoiDiemChinhSua]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_DonViTinh]
    WHERE 
	 ([ID_DonViTinh] = @IDDonViTinh AND @IDDonViTinh is not null)
	OR ([KyHieu] = @KyHieu AND @KyHieu is not null)
	OR ([MacDinh] = @MacDinh AND @MacDinh is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	OR ([ThoiDiemChinhSua] = @ThoiDiemChinhSua AND @ThoiDiemChinhSua is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_DonViTinh_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_DonViTinh table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_DonViTinh]
					, [KyHieu]
					, [MoTa]
					, [MacDinh]
					, [TrangThai]
					, [ThoiDiemChinhSua]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_DonViTinh] {0}
				)
				select
				       [ID_DonViTinh],
				       [KyHieu],
				       [MoTa],
				       [MacDinh],
				       [TrangThai],
				       [ThoiDiemChinhSua],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_DonViTinh] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaCungCapCauHinh_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NhaCungCapCauHinh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NhaCungCap],
					[GiaoDien],
					[NgonNgu],
					[Title],
					[Banner],
					[Logo],
					[Footer]
				FROM
					[dbo].[tb_NhaCungCapCauHinh]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaCungCapCauHinh_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaCungCapCauHinh table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_NhaCungCap]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_NhaCungCap]'
				SET @SQL = @SQL + ', [GiaoDien]'
				SET @SQL = @SQL + ', [NgonNgu]'
				SET @SQL = @SQL + ', [Title]'
				SET @SQL = @SQL + ', [Banner]'
				SET @SQL = @SQL + ', [Logo]'
				SET @SQL = @SQL + ', [Footer]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaCungCapCauHinh]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_NhaCungCap],'
				SET @SQL = @SQL + ' [GiaoDien],'
				SET @SQL = @SQL + ' [NgonNgu],'
				SET @SQL = @SQL + ' [Title],'
				SET @SQL = @SQL + ' [Banner],'
				SET @SQL = @SQL + ' [Logo],'
				SET @SQL = @SQL + ' [Footer]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaCungCapCauHinh]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NhaCungCapCauHinh_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NhaCungCapCauHinh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@GiaoDien" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@NgonNgu" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@Banner" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Logo" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Footer" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NhaCungCapCauHinh]
					(
					[ID_NhaCungCap]
					,[GiaoDien]
					,[NgonNgu]
					,[Title]
					,[Banner]
					,[Logo]
					,[Footer]
					)
				VALUES
					(
					@IDNhaCungCap
					,@GiaoDien
					,@NgonNgu
					,@Title
					,@Banner
					,@Logo
					,@Footer
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapCauHinh_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NhaCungCapCauHinh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@GiaoDien" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@NgonNgu" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@Banner" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Logo" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Footer" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NhaCungCapCauHinh]
				SET
					[ID_NhaCungCap] = @IDNhaCungCap
					,[GiaoDien] = @GiaoDien
					,[NgonNgu] = @NgonNgu
					,[Title] = @Title
					,[Banner] = @Banner
					,[Logo] = @Logo
					,[Footer] = @Footer
				WHERE
[ID_NhaCungCap] = @OriginalIDNhaCungCap 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapCauHinh_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NhaCungCapCauHinh table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NhaCungCapCauHinh] WITH (ROWLOCK) 
				WHERE
					[ID_NhaCungCap] = @IDNhaCungCap
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapCauHinh_GetByIDNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapCauHinh table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NhaCungCap],
					[GiaoDien],
					[NgonNgu],
					[Title],
					[Banner],
					[Logo],
					[Footer]
				FROM
					[dbo].[tb_NhaCungCapCauHinh]
				WHERE
					[ID_NhaCungCap] = @IDNhaCungCap
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapCauHinh_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NhaCungCapCauHinh table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@GiaoDien" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@NgonNgu" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Title" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
				<parameter name="@Banner" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Logo" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Footer" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_NhaCungCap]
	, [GiaoDien]
	, [NgonNgu]
	, [Title]
	, [Banner]
	, [Logo]
	, [Footer]
    FROM
	[dbo].[tb_NhaCungCapCauHinh]
    WHERE 
	 ([ID_NhaCungCap] = @IDNhaCungCap OR @IDNhaCungCap is null)
	AND ([GiaoDien] = @GiaoDien OR @GiaoDien is null)
	AND ([NgonNgu] = @NgonNgu OR @NgonNgu is null)
	AND ([Title] = @Title OR @Title is null)
	AND ([Banner] = @Banner OR @Banner is null)
	AND ([Logo] = @Logo OR @Logo is null)
	AND ([Footer] = @Footer OR @Footer is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_NhaCungCap]
	, [GiaoDien]
	, [NgonNgu]
	, [Title]
	, [Banner]
	, [Logo]
	, [Footer]
    FROM
	[dbo].[tb_NhaCungCapCauHinh]
    WHERE 
	 ([ID_NhaCungCap] = @IDNhaCungCap AND @IDNhaCungCap is not null)
	OR ([GiaoDien] = @GiaoDien AND @GiaoDien is not null)
	OR ([NgonNgu] = @NgonNgu AND @NgonNgu is not null)
	OR ([Title] = @Title AND @Title is not null)
	OR ([Banner] = @Banner AND @Banner is not null)
	OR ([Logo] = @Logo AND @Logo is not null)
	OR ([Footer] = @Footer AND @Footer is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NhaCungCapCauHinh_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaCungCapCauHinh table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_NhaCungCap]
					, [GiaoDien]
					, [NgonNgu]
					, [Title]
					, [Banner]
					, [Logo]
					, [Footer]
					from [dbo].[tb_NhaCungCapCauHinh] {0}
				)
				select
				       [ID_NhaCungCap],
				       [GiaoDien],
				       [NgonNgu],
				       [Title],
				       [Banner],
				       [Logo],
				       [Footer]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NhaCungCapCauHinh] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaCungCapDiaBan_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NhaCungCapDiaBan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_DiaBan],
					[ID_NhaCungCap],
					[ViTri],
					[TrangThai]
				FROM
					[dbo].[tb_NhaCungCapDiaBan]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaCungCapDiaBan_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaCungCapDiaBan table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_DiaBan]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_DiaBan]'
				SET @SQL = @SQL + ', [ID_NhaCungCap]'
				SET @SQL = @SQL + ', [ViTri]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaCungCapDiaBan]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_DiaBan],'
				SET @SQL = @SQL + ' [ID_NhaCungCap],'
				SET @SQL = @SQL + ' [ViTri],'
				SET @SQL = @SQL + ' [TrangThai]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaCungCapDiaBan]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NhaCungCapDiaBan_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NhaCungCapDiaBan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@ViTri" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NhaCungCapDiaBan]
					(
					[ID_DiaBan]
					,[ID_NhaCungCap]
					,[ViTri]
					,[TrangThai]
					)
				VALUES
					(
					@IDDiaBan
					,@IDNhaCungCap
					,@ViTri
					,@TrangThai
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapDiaBan_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NhaCungCapDiaBan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@ViTri" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault=""/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NhaCungCapDiaBan]
				SET
					[ID_DiaBan] = @IDDiaBan
					,[ID_NhaCungCap] = @IDNhaCungCap
					,[ViTri] = @ViTri
					,[TrangThai] = @TrangThai
				WHERE
[ID_DiaBan] = @OriginalIDDiaBan 
AND [ID_NhaCungCap] = @OriginalIDNhaCungCap 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapDiaBan_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NhaCungCapDiaBan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NhaCungCapDiaBan] WITH (ROWLOCK) 
				WHERE
					[ID_DiaBan] = @IDDiaBan
					AND [ID_NhaCungCap] = @IDNhaCungCap
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapDiaBan_GetByIDDiaBan" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapDiaBan table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_DiaBan],
					[ID_NhaCungCap],
					[ViTri],
					[TrangThai]
				FROM
					[dbo].[tb_NhaCungCapDiaBan]
				WHERE
					[ID_DiaBan] = @IDDiaBan
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapDiaBan_GetByIDNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapDiaBan table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_DiaBan],
					[ID_NhaCungCap],
					[ViTri],
					[TrangThai]
				FROM
					[dbo].[tb_NhaCungCapDiaBan]
				WHERE
					[ID_NhaCungCap] = @IDNhaCungCap
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapDiaBan_GetByIDDiaBanIDNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapDiaBan table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_DiaBan],
					[ID_NhaCungCap],
					[ViTri],
					[TrangThai]
				FROM
					[dbo].[tb_NhaCungCapDiaBan]
				WHERE
					[ID_DiaBan] = @IDDiaBan
					AND [ID_NhaCungCap] = @IDNhaCungCap
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapDiaBan_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NhaCungCapDiaBan table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@ViTri" type="int" direction="Input" size="4" precision="10" scale="0" param="" nulldefault="null"/>
				<parameter name="@TrangThai" type="bit" direction="Input" size="1" precision="1" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_DiaBan]
	, [ID_NhaCungCap]
	, [ViTri]
	, [TrangThai]
    FROM
	[dbo].[tb_NhaCungCapDiaBan]
    WHERE 
	 ([ID_DiaBan] = @IDDiaBan OR @IDDiaBan is null)
	AND ([ID_NhaCungCap] = @IDNhaCungCap OR @IDNhaCungCap is null)
	AND ([ViTri] = @ViTri OR @ViTri is null)
	AND ([TrangThai] = @TrangThai OR @TrangThai is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_DiaBan]
	, [ID_NhaCungCap]
	, [ViTri]
	, [TrangThai]
    FROM
	[dbo].[tb_NhaCungCapDiaBan]
    WHERE 
	 ([ID_DiaBan] = @IDDiaBan AND @IDDiaBan is not null)
	OR ([ID_NhaCungCap] = @IDNhaCungCap AND @IDNhaCungCap is not null)
	OR ([ViTri] = @ViTri AND @ViTri is not null)
	OR ([TrangThai] = @TrangThai AND @TrangThai is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NhaCungCapDiaBan_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaCungCapDiaBan table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_DiaBan]
					, [ID_NhaCungCap]
					, [ViTri]
					, [TrangThai]
					from [dbo].[tb_NhaCungCapDiaBan] {0}
				)
				select
				       [ID_DiaBan],
				       [ID_NhaCungCap],
				       [ViTri],
				       [TrangThai]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NhaCungCapDiaBan] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaCungCapLienHe_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NhaCungCapLienHe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NhaCungCapLienHe],
					[ID_NhaCungCap],
					[HoTen],
					[Email],
					[DiaChi],
					[TieuDe],
					[NoiDung],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NhaCungCapLienHe]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NhaCungCapLienHe_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaCungCapLienHe table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_NhaCungCapLienHe]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_NhaCungCapLienHe]'
				SET @SQL = @SQL + ', [ID_NhaCungCap]'
				SET @SQL = @SQL + ', [HoTen]'
				SET @SQL = @SQL + ', [Email]'
				SET @SQL = @SQL + ', [DiaChi]'
				SET @SQL = @SQL + ', [TieuDe]'
				SET @SQL = @SQL + ', [NoiDung]'
				SET @SQL = @SQL + ', [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaCungCapLienHe]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_NhaCungCapLienHe],'
				SET @SQL = @SQL + ' [ID_NhaCungCap],'
				SET @SQL = @SQL + ' [HoTen],'
				SET @SQL = @SQL + ' [Email],'
				SET @SQL = @SQL + ' [DiaChi],'
				SET @SQL = @SQL + ' [TieuDe],'
				SET @SQL = @SQL + ' [NoiDung],'
				SET @SQL = @SQL + ' [ThoiDiemCapNhat]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NhaCungCapLienHe]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NhaCungCapLienHe_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NhaCungCapLienHe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCapLienHe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HoTen" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@DiaChi" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@TieuDe" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@NoiDung" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NhaCungCapLienHe]
					(
					[ID_NhaCungCapLienHe]
					,[ID_NhaCungCap]
					,[HoTen]
					,[Email]
					,[DiaChi]
					,[TieuDe]
					,[NoiDung]
					,[ThoiDiemCapNhat]
					)
				VALUES
					(
					@IDNhaCungCapLienHe
					,@IDNhaCungCap
					,@HoTen
					,@Email
					,@DiaChi
					,@TieuDe
					,@NoiDung
					,@ThoiDiemCapNhat
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapLienHe_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NhaCungCapLienHe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCapLienHe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNhaCungCapLienHe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@HoTen" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault=""/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault=""/>
				<parameter name="@DiaChi" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault=""/>
				<parameter name="@TieuDe" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault=""/>
				<parameter name="@NoiDung" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NhaCungCapLienHe]
				SET
					[ID_NhaCungCapLienHe] = @IDNhaCungCapLienHe
					,[ID_NhaCungCap] = @IDNhaCungCap
					,[HoTen] = @HoTen
					,[Email] = @Email
					,[DiaChi] = @DiaChi
					,[TieuDe] = @TieuDe
					,[NoiDung] = @NoiDung
					,[ThoiDiemCapNhat] = @ThoiDiemCapNhat
				WHERE
[ID_NhaCungCapLienHe] = @OriginalIDNhaCungCapLienHe 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapLienHe_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NhaCungCapLienHe table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCapLienHe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NhaCungCapLienHe] WITH (ROWLOCK) 
				WHERE
					[ID_NhaCungCapLienHe] = @IDNhaCungCapLienHe
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapLienHe_GetByIDNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapLienHe table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NhaCungCapLienHe],
					[ID_NhaCungCap],
					[HoTen],
					[Email],
					[DiaChi],
					[TieuDe],
					[NoiDung],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NhaCungCapLienHe]
				WHERE
					[ID_NhaCungCap] = @IDNhaCungCap
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapLienHe_GetByIDNhaCungCapLienHe" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NhaCungCapLienHe table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCapLienHe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NhaCungCapLienHe],
					[ID_NhaCungCap],
					[HoTen],
					[Email],
					[DiaChi],
					[TieuDe],
					[NoiDung],
					[ThoiDiemCapNhat]
				FROM
					[dbo].[tb_NhaCungCapLienHe]
				WHERE
					[ID_NhaCungCapLienHe] = @IDNhaCungCapLienHe
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NhaCungCapLienHe_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NhaCungCapLienHe table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNhaCungCapLienHe" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@HoTen" type="nvarchar" direction="Input" size="50" precision="0" scale="0" param="(50)" nulldefault="null"/>
				<parameter name="@Email" type="nvarchar" direction="Input" size="255" precision="0" scale="0" param="(255)" nulldefault="null"/>
				<parameter name="@DiaChi" type="nvarchar" direction="Input" size="1024" precision="0" scale="0" param="(1024)" nulldefault="null"/>
				<parameter name="@TieuDe" type="nvarchar" direction="Input" size="200" precision="0" scale="0" param="(200)" nulldefault="null"/>
				<parameter name="@NoiDung" type="ntext" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@ThoiDiemCapNhat" type="datetime" direction="Input" size="8" precision="23" scale="3" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_NhaCungCapLienHe]
	, [ID_NhaCungCap]
	, [HoTen]
	, [Email]
	, [DiaChi]
	, [TieuDe]
	, [NoiDung]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_NhaCungCapLienHe]
    WHERE 
	 ([ID_NhaCungCapLienHe] = @IDNhaCungCapLienHe OR @IDNhaCungCapLienHe is null)
	AND ([ID_NhaCungCap] = @IDNhaCungCap OR @IDNhaCungCap is null)
	AND ([HoTen] = @HoTen OR @HoTen is null)
	AND ([Email] = @Email OR @Email is null)
	AND ([DiaChi] = @DiaChi OR @DiaChi is null)
	AND ([TieuDe] = @TieuDe OR @TieuDe is null)
	AND ([ThoiDiemCapNhat] = @ThoiDiemCapNhat OR @ThoiDiemCapNhat is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_NhaCungCapLienHe]
	, [ID_NhaCungCap]
	, [HoTen]
	, [Email]
	, [DiaChi]
	, [TieuDe]
	, [NoiDung]
	, [ThoiDiemCapNhat]
    FROM
	[dbo].[tb_NhaCungCapLienHe]
    WHERE 
	 ([ID_NhaCungCapLienHe] = @IDNhaCungCapLienHe AND @IDNhaCungCapLienHe is not null)
	OR ([ID_NhaCungCap] = @IDNhaCungCap AND @IDNhaCungCap is not null)
	OR ([HoTen] = @HoTen AND @HoTen is not null)
	OR ([Email] = @Email AND @Email is not null)
	OR ([DiaChi] = @DiaChi AND @DiaChi is not null)
	OR ([TieuDe] = @TieuDe AND @TieuDe is not null)
	OR ([ThoiDiemCapNhat] = @ThoiDiemCapNhat AND @ThoiDiemCapNhat is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NhaCungCapLienHe_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NhaCungCapLienHe table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_NhaCungCapLienHe]
					, [ID_NhaCungCap]
					, [HoTen]
					, [Email]
					, [DiaChi]
					, [TieuDe]
					, [NoiDung]
					, [ThoiDiemCapNhat]
					from [dbo].[tb_NhaCungCapLienHe] {0}
				)
				select
				       [ID_NhaCungCapLienHe],
				       [ID_NhaCungCap],
				       [HoTen],
				       [Email],
				       [DiaChi],
				       [TieuDe],
				       [NoiDung],
				       [ThoiDiemCapNhat]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NhaCungCapLienHe] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NguoiDungVaiTro_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NguoiDungVaiTro table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_VaiTro],
					[ID_NguoiDung]
				FROM
					[dbo].[tb_NguoiDungVaiTro]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NguoiDungVaiTro_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NguoiDungVaiTro table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_VaiTro]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_VaiTro]'
				SET @SQL = @SQL + ', [ID_NguoiDung]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NguoiDungVaiTro]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_VaiTro],'
				SET @SQL = @SQL + ' [ID_NguoiDung]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NguoiDungVaiTro]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NguoiDungVaiTro_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NguoiDungVaiTro table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NguoiDungVaiTro]
					(
					[ID_VaiTro]
					,[ID_NguoiDung]
					)
				VALUES
					(
					@IDVaiTro
					,@IDNguoiDung
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungVaiTro_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NguoiDungVaiTro table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NguoiDungVaiTro]
				SET
					[ID_VaiTro] = @IDVaiTro
					,[ID_NguoiDung] = @IDNguoiDung
				WHERE
[ID_VaiTro] = @OriginalIDVaiTro 
AND [ID_NguoiDung] = @OriginalIDNguoiDung 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungVaiTro_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NguoiDungVaiTro table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NguoiDungVaiTro] WITH (ROWLOCK) 
				WHERE
					[ID_VaiTro] = @IDVaiTro
					AND [ID_NguoiDung] = @IDNguoiDung
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungVaiTro_GetByIDNguoiDung" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDungVaiTro table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_VaiTro],
					[ID_NguoiDung]
				FROM
					[dbo].[tb_NguoiDungVaiTro]
				WHERE
					[ID_NguoiDung] = @IDNguoiDung
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungVaiTro_GetByIDVaiTro" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDungVaiTro table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_VaiTro],
					[ID_NguoiDung]
				FROM
					[dbo].[tb_NguoiDungVaiTro]
				WHERE
					[ID_VaiTro] = @IDVaiTro
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungVaiTro_GetByIDVaiTroIDNguoiDung" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDungVaiTro table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_VaiTro],
					[ID_NguoiDung]
				FROM
					[dbo].[tb_NguoiDungVaiTro]
				WHERE
					[ID_VaiTro] = @IDVaiTro
					AND [ID_NguoiDung] = @IDNguoiDung
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungVaiTro_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NguoiDungVaiTro table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDVaiTro" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_VaiTro]
	, [ID_NguoiDung]
    FROM
	[dbo].[tb_NguoiDungVaiTro]
    WHERE 
	 ([ID_VaiTro] = @IDVaiTro OR @IDVaiTro is null)
	AND ([ID_NguoiDung] = @IDNguoiDung OR @IDNguoiDung is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_VaiTro]
	, [ID_NguoiDung]
    FROM
	[dbo].[tb_NguoiDungVaiTro]
    WHERE 
	 ([ID_VaiTro] = @IDVaiTro AND @IDVaiTro is not null)
	OR ([ID_NguoiDung] = @IDNguoiDung AND @IDNguoiDung is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NguoiDungVaiTro_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NguoiDungVaiTro table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_VaiTro]
					, [ID_NguoiDung]
					from [dbo].[tb_NguoiDungVaiTro] {0}
				)
				select
				       [ID_VaiTro],
				       [ID_NguoiDung]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NguoiDungVaiTro] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NguoiDungDiaBan_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NguoiDungDiaBan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_DiaBan],
					[ID_NguoiDung]
				FROM
					[dbo].[tb_NguoiDungDiaBan]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NguoiDungDiaBan_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NguoiDungDiaBan table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_DiaBan]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_DiaBan]'
				SET @SQL = @SQL + ', [ID_NguoiDung]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NguoiDungDiaBan]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_DiaBan],'
				SET @SQL = @SQL + ' [ID_NguoiDung]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NguoiDungDiaBan]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NguoiDungDiaBan_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NguoiDungDiaBan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NguoiDungDiaBan]
					(
					[ID_DiaBan]
					,[ID_NguoiDung]
					)
				VALUES
					(
					@IDDiaBan
					,@IDNguoiDung
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungDiaBan_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NguoiDungDiaBan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NguoiDungDiaBan]
				SET
					[ID_DiaBan] = @IDDiaBan
					,[ID_NguoiDung] = @IDNguoiDung
				WHERE
[ID_DiaBan] = @OriginalIDDiaBan 
AND [ID_NguoiDung] = @OriginalIDNguoiDung 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungDiaBan_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NguoiDungDiaBan table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NguoiDungDiaBan] WITH (ROWLOCK) 
				WHERE
					[ID_DiaBan] = @IDDiaBan
					AND [ID_NguoiDung] = @IDNguoiDung
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungDiaBan_GetByIDNguoiDung" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDungDiaBan table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_DiaBan],
					[ID_NguoiDung]
				FROM
					[dbo].[tb_NguoiDungDiaBan]
				WHERE
					[ID_NguoiDung] = @IDNguoiDung
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungDiaBan_GetByIDDiaBan" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDungDiaBan table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_DiaBan],
					[ID_NguoiDung]
				FROM
					[dbo].[tb_NguoiDungDiaBan]
				WHERE
					[ID_DiaBan] = @IDDiaBan
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungDiaBan_GetByIDDiaBanIDNguoiDung" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDungDiaBan table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_DiaBan],
					[ID_NguoiDung]
				FROM
					[dbo].[tb_NguoiDungDiaBan]
				WHERE
					[ID_DiaBan] = @IDDiaBan
					AND [ID_NguoiDung] = @IDNguoiDung
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungDiaBan_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NguoiDungDiaBan table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDDiaBan" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_DiaBan]
	, [ID_NguoiDung]
    FROM
	[dbo].[tb_NguoiDungDiaBan]
    WHERE 
	 ([ID_DiaBan] = @IDDiaBan OR @IDDiaBan is null)
	AND ([ID_NguoiDung] = @IDNguoiDung OR @IDNguoiDung is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_DiaBan]
	, [ID_NguoiDung]
    FROM
	[dbo].[tb_NguoiDungDiaBan]
    WHERE 
	 ([ID_DiaBan] = @IDDiaBan AND @IDDiaBan is not null)
	OR ([ID_NguoiDung] = @IDNguoiDung AND @IDNguoiDung is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NguoiDungDiaBan_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NguoiDungDiaBan table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_DiaBan]
					, [ID_NguoiDung]
					from [dbo].[tb_NguoiDungDiaBan] {0}
				)
				select
				       [ID_DiaBan],
				       [ID_NguoiDung]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NguoiDungDiaBan] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NguoiDungNgheNghiep_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NguoiDungNgheNghiep table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NguoiDung],
					[ID_NgheNghiep]
				FROM
					[dbo].[tb_NguoiDungNgheNghiep]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NguoiDungNgheNghiep_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NguoiDungNgheNghiep table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_NguoiDung]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_NguoiDung]'
				SET @SQL = @SQL + ', [ID_NgheNghiep]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NguoiDungNgheNghiep]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_NguoiDung],'
				SET @SQL = @SQL + ' [ID_NgheNghiep]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NguoiDungNgheNghiep]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NguoiDungNgheNghiep_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NguoiDungNgheNghiep table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NguoiDungNgheNghiep]
					(
					[ID_NguoiDung]
					,[ID_NgheNghiep]
					)
				VALUES
					(
					@IDNguoiDung
					,@IDNgheNghiep
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungNgheNghiep_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NguoiDungNgheNghiep table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NguoiDungNgheNghiep]
				SET
					[ID_NguoiDung] = @IDNguoiDung
					,[ID_NgheNghiep] = @IDNgheNghiep
				WHERE
[ID_NguoiDung] = @OriginalIDNguoiDung 
AND [ID_NgheNghiep] = @OriginalIDNgheNghiep 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungNgheNghiep_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NguoiDungNgheNghiep table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NguoiDungNgheNghiep] WITH (ROWLOCK) 
				WHERE
					[ID_NguoiDung] = @IDNguoiDung
					AND [ID_NgheNghiep] = @IDNgheNghiep
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungNgheNghiep_GetByIDNgheNghiep" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDungNgheNghiep table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NguoiDung],
					[ID_NgheNghiep]
				FROM
					[dbo].[tb_NguoiDungNgheNghiep]
				WHERE
					[ID_NgheNghiep] = @IDNgheNghiep
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungNgheNghiep_GetByIDNguoiDung" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDungNgheNghiep table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NguoiDung],
					[ID_NgheNghiep]
				FROM
					[dbo].[tb_NguoiDungNgheNghiep]
				WHERE
					[ID_NguoiDung] = @IDNguoiDung
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungNgheNghiep_GetByIDNguoiDungIDNgheNghiep" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDungNgheNghiep table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NguoiDung],
					[ID_NgheNghiep]
				FROM
					[dbo].[tb_NguoiDungNgheNghiep]
				WHERE
					[ID_NguoiDung] = @IDNguoiDung
					AND [ID_NgheNghiep] = @IDNgheNghiep
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungNgheNghiep_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NguoiDungNgheNghiep table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNgheNghiep" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_NguoiDung]
	, [ID_NgheNghiep]
    FROM
	[dbo].[tb_NguoiDungNgheNghiep]
    WHERE 
	 ([ID_NguoiDung] = @IDNguoiDung OR @IDNguoiDung is null)
	AND ([ID_NgheNghiep] = @IDNgheNghiep OR @IDNgheNghiep is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_NguoiDung]
	, [ID_NgheNghiep]
    FROM
	[dbo].[tb_NguoiDungNgheNghiep]
    WHERE 
	 ([ID_NguoiDung] = @IDNguoiDung AND @IDNguoiDung is not null)
	OR ([ID_NgheNghiep] = @IDNgheNghiep AND @IDNgheNghiep is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NguoiDungNgheNghiep_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NguoiDungNgheNghiep table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_NguoiDung]
					, [ID_NgheNghiep]
					from [dbo].[tb_NguoiDungNgheNghiep] {0}
				)
				select
				       [ID_NguoiDung],
				       [ID_NgheNghiep]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NguoiDungNgheNghiep] {0};
			
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NguoiDungNhaCungCap_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the tb_NguoiDungNhaCungCap table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NguoiDung],
					[ID_NhaCungCap]
				FROM
					[dbo].[tb_NguoiDungNhaCungCap]
					
				Select @@ROWCOUNT
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="tb_NguoiDungNhaCungCap_GetPaged" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NguoiDungNhaCungCap table passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_NguoiDung]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_NguoiDung]'
				SET @SQL = @SQL + ', [ID_NhaCungCap]'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NguoiDungNhaCungCap]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_NguoiDung],'
				SET @SQL = @SQL + ' [ID_NhaCungCap]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ORDER BY ' + @OrderBy
				exec sp_executesql @SQL
				
				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[tb_NguoiDungNhaCungCap]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="tb_NguoiDungNhaCungCap_Insert" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Inserts a record into the tb_NguoiDungNhaCungCap table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE	
				INSERT INTO [dbo].[tb_NguoiDungNhaCungCap]
					(
					[ID_NguoiDung]
					,[ID_NhaCungCap]
					)
				VALUES
					(
					@IDNguoiDung
					,@IDNhaCungCap
					)
				
									
							
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungNhaCungCap_Update" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Updates a record in the tb_NguoiDungNhaCungCap table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@OriginalIDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				
				-- Modify the updatable columns
				UPDATE
					[dbo].[tb_NguoiDungNhaCungCap]
				SET
					[ID_NguoiDung] = @IDNguoiDung
					,[ID_NhaCungCap] = @IDNhaCungCap
				WHERE
[ID_NguoiDung] = @OriginalIDNguoiDung 
AND [ID_NhaCungCap] = @OriginalIDNhaCungCap 
				
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungNhaCungCap_Delete" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Deletes a record in the tb_NguoiDungNhaCungCap table
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				DELETE FROM [dbo].[tb_NguoiDungNhaCungCap] WITH (ROWLOCK) 
				WHERE
					[ID_NguoiDung] = @IDNguoiDung
					AND [ID_NhaCungCap] = @IDNhaCungCap
					
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungNhaCungCap_GetByIDNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDungNhaCungCap table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NguoiDung],
					[ID_NhaCungCap]
				FROM
					[dbo].[tb_NguoiDungNhaCungCap]
				WHERE
					[ID_NhaCungCap] = @IDNhaCungCap
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungNhaCungCap_GetByIDNguoiDung" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDungNhaCungCap table through a foreign key
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SET ANSI_NULLS OFF
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_NguoiDung],
					[ID_NhaCungCap]
				FROM
					[dbo].[tb_NguoiDungNhaCungCap]
				WHERE
					[ID_NguoiDung] = @IDNguoiDung
				
				Select @@ROWCOUNT
				SET ANSI_NULLS ON
			]]></body>
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungNhaCungCap_GetByIDNguoiDungIDNhaCungCap" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Select records from the tb_NguoiDungNhaCungCap table through an index
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault=""/>
			</parameters>
			<body><![CDATA[
				SELECT
					[ID_NguoiDung],
					[ID_NhaCungCap]
				FROM
					[dbo].[tb_NguoiDungNhaCungCap]
				WHERE
					[ID_NguoiDung] = @IDNguoiDung
					AND [ID_NhaCungCap] = @IDNhaCungCap
			Select @@ROWCOUNT
					
			]]></body>
			
		</procedure>
		<procedure owner="dbo" name="tb_NguoiDungNhaCungCap_Find" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Finds records in the tb_NguoiDungNhaCungCap table passing nullable parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@SearchUsingOR" type="bit" direction="Input" size="0" precision="1" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNguoiDung" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
				<parameter name="@IDNhaCungCap" type="uniqueidentifier" direction="Input" size="16" precision="0" scale="0" param="" nulldefault="null"/>
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
	  [ID_NguoiDung]
	, [ID_NhaCungCap]
    FROM
	[dbo].[tb_NguoiDungNhaCungCap]
    WHERE 
	 ([ID_NguoiDung] = @IDNguoiDung OR @IDNguoiDung is null)
	AND ([ID_NhaCungCap] = @IDNhaCungCap OR @IDNhaCungCap is null)
						
  END
  ELSE
  BEGIN
    SELECT
	  [ID_NguoiDung]
	, [ID_NhaCungCap]
    FROM
	[dbo].[tb_NguoiDungNhaCungCap]
    WHERE 
	 ([ID_NguoiDung] = @IDNguoiDung AND @IDNguoiDung is not null)
	OR ([ID_NhaCungCap] = @IDNhaCungCap AND @IDNhaCungCap is not null)
	Select @@ROWCOUNT			
  END
				]]></body>
		</procedure>

		
		<procedure owner="dbo" name="tb_NguoiDungNhaCungCap_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the tb_NguoiDungNhaCungCap table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_NguoiDung]
					, [ID_NhaCungCap]
					from [dbo].[tb_NguoiDungNhaCungCap] {0}
				)
				select
				       [ID_NguoiDung],
				       [ID_NhaCungCap]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};
				

				-- get total count
				select count(*) as TotalRowCount from [dbo].[tb_NguoiDungNhaCungCap] {0};
			
				END
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="View_BangGiaSanPham_Get_List" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets all records from the View_BangGiaSanPham view
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				SELECT
					[ID_SanPham],
					[ID_NhaCungCap],
					[ID_DiaBan],
					[KichHoat],
					[ChungThuc],
					[TrangThai],
					[ChoNhapGia],
					[DonGia],
					[VAT],
					[SoLuongTrongKho],
					[TieuChuanKyThuat],
					[Thongtinthem],
					[ThoiDiemDangBaoGia],
					[ThoiDiemHetHieuLuc],
					[NgoaiTe],
					[TenNgoaiTe],
					[TyGia],
					[MaDiaBan],
					[NhaCungCap],
					[TenNhaCungCap],
					[ID_SanPhamDanhMuc],
					[TenSanPham],
					[MoTaSanPham],
					[NhaSanXuat],
					[DonViTinh],
					[HinhMinhHoa],
					[TrangThaiSanPham],
					[SoLanXem],
					[TenSanPhamDanhMuc],
					[MoTaSanPhamDanhMuc],
					[HinhMinhHoaSanPhamDanhMuc],
					[KeyBangGia]
				FROM
					[dbo].[View_BangGiaSanPham]
					
				Select @@ROWCOUNT			
			]]></body>
		</procedure>
		
		<procedure owner="dbo" name="View_BangGiaSanPham_Get" grant="">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the View_BangGiaSanPham view passing page index and page count parameters
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters>
				<parameter name="@WhereClause" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)" />
				<parameter name="@OrderBy" type="varchar" direction="Input" size="2000" precision="0" scale="0" param="(2000)"/>			
				<parameter name="@PageIndex" type="int" direction="Input" size="0" precision="10" scale="0" />
				<parameter name="@PageSize" type="int" direction="Input" size="0" precision="10" scale="0" /> 
			</parameters>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN

				DECLARE @PageLowerBound int
				DECLARE @PageUpperBound int
				
				-- Set the page bounds
				SET @PageLowerBound = @PageSize * @PageIndex
				SET @PageUpperBound = @PageLowerBound + @PageSize

				IF (@OrderBy is null or LEN(@OrderBy) < 1)
				BEGIN
					-- default order by to first column
					SET @OrderBy = '[ID_SanPham]'
				END

				-- SQL Server 2005 Paging
				declare @SQL as nvarchar(4000)
				SET @SQL = 'WITH PageIndex AS ('
				SET @SQL = @SQL + ' SELECT'
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' TOP ' + convert(nvarchar, @PageUpperBound)
				END
				SET @SQL = @SQL + ' ROW_NUMBER() OVER (ORDER BY ' + @OrderBy + ') as RowIndex'
				SET @SQL = @SQL + ', [ID_SanPham]'
				SET @SQL = @SQL + ', [ID_NhaCungCap]'
				SET @SQL = @SQL + ', [ID_DiaBan]'
				SET @SQL = @SQL + ', [KichHoat]'
				SET @SQL = @SQL + ', [ChungThuc]'
				SET @SQL = @SQL + ', [TrangThai]'
				SET @SQL = @SQL + ', [ChoNhapGia]'
				SET @SQL = @SQL + ', [DonGia]'
				SET @SQL = @SQL + ', [VAT]'
				SET @SQL = @SQL + ', [SoLuongTrongKho]'
				SET @SQL = @SQL + ', [TieuChuanKyThuat]'
				SET @SQL = @SQL + ', [Thongtinthem]'
				SET @SQL = @SQL + ', [ThoiDiemDangBaoGia]'
				SET @SQL = @SQL + ', [ThoiDiemHetHieuLuc]'
				SET @SQL = @SQL + ', [NgoaiTe]'
				SET @SQL = @SQL + ', [TenNgoaiTe]'
				SET @SQL = @SQL + ', [TyGia]'
				SET @SQL = @SQL + ', [MaDiaBan]'
				SET @SQL = @SQL + ', [NhaCungCap]'
				SET @SQL = @SQL + ', [TenNhaCungCap]'
				SET @SQL = @SQL + ', [ID_SanPhamDanhMuc]'
				SET @SQL = @SQL + ', [TenSanPham]'
				SET @SQL = @SQL + ', [MoTaSanPham]'
				SET @SQL = @SQL + ', [NhaSanXuat]'
				SET @SQL = @SQL + ', [DonViTinh]'
				SET @SQL = @SQL + ', [HinhMinhHoa]'
				SET @SQL = @SQL + ', [TrangThaiSanPham]'
				SET @SQL = @SQL + ', [SoLanXem]'
				SET @SQL = @SQL + ', [TenSanPhamDanhMuc]'
				SET @SQL = @SQL + ', [MoTaSanPhamDanhMuc]'
				SET @SQL = @SQL + ', [HinhMinhHoaSanPhamDanhMuc]'
				SET @SQL = @SQL + ', [KeyBangGia]'
				SET @SQL = @SQL + ' FROM [dbo].[View_BangGiaSanPham]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				SET @SQL = @SQL + ' ) SELECT'
				SET @SQL = @SQL + ' [ID_SanPham],'
				SET @SQL = @SQL + ' [ID_NhaCungCap],'
				SET @SQL = @SQL + ' [ID_DiaBan],'
				SET @SQL = @SQL + ' [KichHoat],'
				SET @SQL = @SQL + ' [ChungThuc],'
				SET @SQL = @SQL + ' [TrangThai],'
				SET @SQL = @SQL + ' [ChoNhapGia],'
				SET @SQL = @SQL + ' [DonGia],'
				SET @SQL = @SQL + ' [VAT],'
				SET @SQL = @SQL + ' [SoLuongTrongKho],'
				SET @SQL = @SQL + ' [TieuChuanKyThuat],'
				SET @SQL = @SQL + ' [Thongtinthem],'
				SET @SQL = @SQL + ' [ThoiDiemDangBaoGia],'
				SET @SQL = @SQL + ' [ThoiDiemHetHieuLuc],'
				SET @SQL = @SQL + ' [NgoaiTe],'
				SET @SQL = @SQL + ' [TenNgoaiTe],'
				SET @SQL = @SQL + ' [TyGia],'
				SET @SQL = @SQL + ' [MaDiaBan],'
				SET @SQL = @SQL + ' [NhaCungCap],'
				SET @SQL = @SQL + ' [TenNhaCungCap],'
				SET @SQL = @SQL + ' [ID_SanPhamDanhMuc],'
				SET @SQL = @SQL + ' [TenSanPham],'
				SET @SQL = @SQL + ' [MoTaSanPham],'
				SET @SQL = @SQL + ' [NhaSanXuat],'
				SET @SQL = @SQL + ' [DonViTinh],'
				SET @SQL = @SQL + ' [HinhMinhHoa],'
				SET @SQL = @SQL + ' [TrangThaiSanPham],'
				SET @SQL = @SQL + ' [SoLanXem],'
				SET @SQL = @SQL + ' [TenSanPhamDanhMuc],'
				SET @SQL = @SQL + ' [MoTaSanPhamDanhMuc],'
				SET @SQL = @SQL + ' [HinhMinhHoaSanPhamDanhMuc],'
				SET @SQL = @SQL + ' [KeyBangGia]'
				SET @SQL = @SQL + ' FROM PageIndex'
				SET @SQL = @SQL + ' WHERE RowIndex > ' + convert(nvarchar, @PageLowerBound)
				IF @PageSize > 0
				BEGIN
					SET @SQL = @SQL + ' AND RowIndex <= ' + convert(nvarchar, @PageUpperBound)
				END
				exec sp_executesql @SQL

				-- get row count
				SET @SQL = 'SELECT COUNT(*) as TotalRowCount'
				SET @SQL = @SQL + ' FROM [dbo].[View_BangGiaSanPham]'
				IF LEN(@WhereClause) > 0
				BEGIN
					SET @SQL = @SQL + ' WHERE ' + @WhereClause
				END
				exec sp_executesql @SQL
				
				END
			]]></body>
		</procedure>
		
		
		<procedure owner="dbo" name="View_BangGiaSanPham_Find_Dynamic" grant="" skip="true">
			<comment><![CDATA[/*
----------------------------------------------------------------------------------------------------
-- Date Created: Friday, June 06, 2008

-- Created By: Indeco (http://www.gia24.vn)
-- Purpose: Gets records from the View_BangGiaSanPham table using a dynamically generated query.
----------------------------------------------------------------------------------------------------
*/
]]></comment>
			<parameters/>
			<body><![CDATA[
				SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
				BEGIN
				
				with PageIndex as (
					select top {3} row_number() over (order by {1}) as RowIndex
					, [ID_SanPham]
					, [ID_NhaCungCap]
					, [ID_DiaBan]
					, [KichHoat]
					, [ChungThuc]
					, [TrangThai]
					, [ChoNhapGia]
					, [DonGia]
					, [VAT]
					, [SoLuongTrongKho]
					, [TieuChuanKyThuat]
					, [Thongtinthem]
					, [ThoiDiemDangBaoGia]
					, [ThoiDiemHetHieuLuc]
					, [NgoaiTe]
					, [TenNgoaiTe]
					, [TyGia]
					, [MaDiaBan]
					, [NhaCungCap]
					, [TenNhaCungCap]
					, [ID_SanPhamDanhMuc]
					, [TenSanPham]
					, [MoTaSanPham]
					, [NhaSanXuat]
					, [DonViTinh]
					, [HinhMinhHoa]
					, [TrangThaiSanPham]
					, [SoLanXem]
					, [TenSanPhamDanhMuc]
					, [MoTaSanPhamDanhMuc]
					, [HinhMinhHoaSanPhamDanhMuc]
					, [KeyBangGia]
					from [dbo].[View_BangGiaSanPham] {0}
				)
				select
				       [ID_SanPham],
				       [ID_NhaCungCap],
				       [ID_DiaBan],
				       [KichHoat],
				       [ChungThuc],
				       [TrangThai],
				       [ChoNhapGia],
				       [DonGia],
				       [VAT],
				       [SoLuongTrongKho],
				       [TieuChuanKyThuat],
				       [Thongtinthem],
				       [ThoiDiemDangBaoGia],
				       [ThoiDiemHetHieuLuc],
				       [NgoaiTe],
				       [TenNgoaiTe],
				       [TyGia],
				       [MaDiaBan],
				       [NhaCungCap],
				       [TenNhaCungCap],
				       [ID_SanPhamDanhMuc],
				       [TenSanPham],
				       [MoTaSanPham],
				       [NhaSanXuat],
				       [DonViTinh],
				       [HinhMinhHoa],
				       [TrangThaiSanPham],
				       [SoLanXem],
				       [TenSanPhamDanhMuc],
				       [MoTaSanPhamDanhMuc],
				       [HinhMinhHoaSanPhamDanhMuc],
				       [KeyBangGia]
				  from PageIndex
				 where RowIndex > {2}
				   and RowIndex <= {3};

				-- get total count
				select count(*) as TotalRowCount from [dbo].[View_BangGiaSanPham] {0};
				
				END
			]]></body>
		</procedure>
		
</procedures>
</root>
